Drop duplicated opening-quote fragments in the manuscript Format pass#1275
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the manuscript Format button (#1273/#1274). Running Format on a real manuscript left a stray
"Ion 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 —The lone closing
"and the wrapped quotes are already re-attached by the existing passes, but the duplicated"Isurvived as a stray — reflow couldn't absorb it because the next line also starts with a quote.Fix: a prose-only
dropDuplicatedQuoteFragmentspass. 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:"Yes./"No.(terminal punctuation, not a fragment)"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
"Ientirely 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.eslintclean.