Skip to content

Drop duplicated opening-quote fragments in the manuscript Format pass#1275

Merged
atomantic merged 2 commits into
mainfrom
fix/manuscript-format-duplicate-quote-fragment
Jun 15, 2026
Merged

Drop duplicated opening-quote fragments in the manuscript Format pass#1275
atomantic merged 2 commits into
mainfrom
fix/manuscript-format-duplicate-quote-fragment

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

Follow-up to the manuscript Format button (#1273/#1274). Running Format on a real manuscript left a stray "I on its own line. Reproduced against the actual stored source, the cause is a PDF/LLM export defect: the dialogue's opening quote is duplicated onto its own line just before the real quoted paragraph —

hear you need a calibration partner.
"
"I
"I need a calibration partner who knows …

The lone closing " and the wrapped quotes are already re-attached by the existing passes, but the duplicated "I survived as a stray — reflow couldn't absorb it because the next line also starts with a quote.

Fix: a prose-only dropDuplicatedQuoteFragments pass. It drops a short incomplete opening-quote fragment line (a " plus a few non-terminal chars, no closing quote) only when the next line begins with that exact fragment followed by a word boundary. Tightly guarded so it never touches:

  • genuine back-to-back short dialogue — "Yes. / "No. (terminal punctuation, not a fragment)
  • a merely-similar next word — "I / "Information (no word boundary after the prefix)

Verified against the real stored passage; the output is idempotent.

Known limit: where the export dropped the "I entirely before a word (placard,\nhear), the text is genuinely lost in the source and can't be reconstructed — that line stays as-is.

Test plan

  • client/src/lib/manuscriptFormat.test.js — new tests: the duplicated-fragment drop (against the real passage shape), the back-to-back-dialogue guard, and the similar-prefix guard. 26 tests in the file, all green.
  • eslint clean.

PDF/LLM exports sometimes copy a dialogue's opening quote onto its own line
just before the real quoted paragraph:

    hear you need a calibration partner.
    "
    "I
    "I need a calibration partner who knows …

The lone closing `"` and the wrapped quotes are already re-attached, but the
duplicated `"I` survived as a stray that reflow couldn't absorb (the next line
also starts with a quote). Add a prose-only dropDuplicatedQuoteFragments pass:
it drops a short INCOMPLETE opening-quote fragment line (a `"` plus a few
non-terminal chars, no closing quote) only when the next line begins with that
exact fragment followed by a word boundary — so real back-to-back dialogue
("Yes. / "No.) and a merely-similar next word ("I / "Information) are left
alone. Verified against the real stored passage; idempotent.

(Residual source damage where the export dropped the `"I ` entirely before a
word — `placard,\nhear` — is not recoverable and is left as-is.)
…pace boundary

The word-boundary (\W) check would drop a legitimate short utterance that is a word-prefix of the next line continuing into a new clause ("Wait before "Wait, no — …). A true duplicated opening fragment always continues with whitespace ("I → "I need …), so gate on a whitespace boundary (or exact full-duplicate) instead. Added the collision guard test and an idempotency test.
@atomantic atomantic merged commit 22b747a into main Jun 15, 2026
2 checks passed
@atomantic atomantic deleted the fix/manuscript-format-duplicate-quote-fragment branch June 15, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant