fix: unify export content across formats (title, soft breaks, comments)#61
Merged
Merged
Conversation
Three content inconsistencies between export formats, all causing output to diverge from the source: 1. Title duplication with body's first H1 When a document started with a level-1 heading, each format prepended its own title (# / <h1> / Title style) on top of the heading still in the body, producing a duplicate. DocumentAssembler now extracts a leading H1 as the document title and removes it from the body (extractLeadingH1); when there is no leading H1 the filename-derived title is used unchanged. 2. Markdown embed empty alt text LinkRewriter.formatEmbed emitted  with empty alt for the markdown-bundle profile, which Obsidian and many viewers do not render as an image. Now uses the link text as alt, matching the docx/html/pdf branches. 3. docx soft line breaks became separate paragraphs parseMarkdownToParagraphs split on every newline, so adjacent non-blank lines (Obsidian soft breaks in one paragraph) each became their own <w:p> with large spacing. Consecutive plain-text lines are now aggregated into one paragraph separated by <w:br/>. 4. docx rendered source-path comments as literal text <!-- source: ... --> lines appeared as visible body text in docx. HTML comment lines are now skipped during paragraph parsing. Tests: 164 pass (added extractLeadingH1, soft-break aggregation, and comment-skipping coverage).
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.
Problem
Exported content diverged from the source in ways that differed across the four formats. Investigation (filename vs content) found the filenames are already consistent (all formats write the same
outputFilePathfrom ExportRunner). The issues are all in content layer:Fixes
1. Title duplication with body's first H1
When a document started with a level-1 heading, every format prepended its own title (
#/<h1>/ Title style) on top of that heading still present in the body → duplicate title.Fix:
DocumentAssemblernow extracts a leading# Headingas the document title and removes it from the body (extractLeadingH1). When there's no leading H1, the filename-derived title is used unchanged. Affects all formats uniformly.# filename+# original heading(duplicate)# original heading(no duplicate)# filename(no H1 in body)# filename(unchanged)2. Markdown embed empty alt text
LinkRewriter.formatEmbedemittedwith empty alt for the markdown-bundle profile. Obsidian (and many viewers) don't render images with empty alt, so images were invisible.Fix: Now uses the link text as alt (
), matching the docx/html/pdf branches.3. docx soft line breaks became separate paragraphs
parseMarkdownToParagraphssplit on every\n, so adjacent non-blank lines (Obsidian soft breaks within one paragraph) each became their own<w:p>with large paragraph spacing.Fix: Consecutive plain-text lines are now aggregated into one paragraph, separated by
<w:br/>, matching how Obsidian renders them.4. docx rendered source-path comments as literal text
<!-- source: path -->lines appeared as visible body text in docx.Fix: HTML comment lines are skipped during paragraph parsing.
Not changed
![[img.png|258]]): the|widthObsidian syntax is stripped upstream in LinkRewriter for all formats. Standard Markdown cannot express it; preserving it would require HTML<img width>in markdown-bundle, which is out of scope.Tests
164 pass (added
extractLeadingH1, soft-break aggregation, comment-skipping coverage).