refactored the entire structure for the new product line

This commit is contained in:
2026-09-04 09:41:02 -05:00
parent 0c18960106
commit b4dd487a94
102 changed files with 3980 additions and 3091 deletions
@@ -0,0 +1,86 @@
Fix ChatGPT DOM extractor formatting defects discovered during manual testing.
Observed defects:
1. Bold text is being extracted with comma-like artifacts instead of Markdown emphasis.
Example bad output:
what we know
,
what is plausible
, and
what is not supported by the evidence
.
Expected output:
**what we know**, **what is plausible**, and **what is not supported by the evidence**.
2. Quoted text is being surrounded by em-dash artifacts.
Example bad output:
So the author's central educational point—
"Jet streams matter."
—is absolutely correct.
Expected output:
So the author's central educational point — "Jet streams matter." — is absolutely correct.
Likely cause:
The extractor is walking DOM nodes and treating presentational or punctuation-only nodes incorrectly, especially around strong/bold tags and quotation/punctuation boundaries.
Requirements:
1. Update src/chatgptExtractor.js only unless integration requires a small change elsewhere.
2. Improve inline formatting extraction:
- Convert <strong> and <b> to Markdown bold: **text**
- Convert <em> and <i> to Markdown italics: *text*
- Convert inline <code> to `text`
- Preserve surrounding punctuation in natural sentence order.
- Do not emit isolated punctuation artifacts on separate lines.
3. Fix punctuation spacing:
- Do not place commas, periods, semicolons, colons, exclamation marks, or question marks on their own line.
- Attach closing punctuation to the preceding token.
- Preserve spaces between words.
- Avoid inserting line breaks between inline elements unless the source node is block-level.
4. Fix quote/em-dash handling:
- Do not treat em dashes as block separators.
- Keep em dashes inline with surrounding text.
- Normalize this pattern:
text—
"quote"
—text
into readable inline prose where possible.
5. Preserve block formatting:
- Paragraphs should remain paragraphs.
- Lists should remain readable.
- Code blocks should still use fenced Markdown.
- Headings should remain Markdown headings where already implemented.
6. Add helper functions if useful:
- isInlineElement(node)
- isBlockElement(node)
- appendInlineText(parts, text)
- normalizeInlineMarkdown(text)
- cleanupPunctuationSpacing(text)
7. Add lightweight manual test fixtures or comments with examples:
- bold phrase followed by comma
- bold phrase followed by comma and another bold phrase
- quoted phrase surrounded by em dashes
- assistant message with paragraph + list + code block
8. Do not add AI processing.
9. Do not change Markdown normalizer behavior unless absolutely necessary.
10. Do not change download writer behavior.
Acceptance criteria:
- Bold text exports as **bold text**.
- Italics export as *italic text*.
- Inline code exports as `inline code`.
- Commas remain attached to the correct phrase.
- Em dashes remain inline and readable.
- No punctuation-only lines are introduced by inline formatting.
- Code blocks remain intact.
- Message order and role detection still work.