fix: convert tables containing bullet lists to Markdown (#6)#7
Merged
Conversation
Confluence table cells containing a bullet or numbered list were left as raw HTML because pandoc's GFM writer cannot place block-level content in a pipe table cell and falls back to emitting the entire table as HTML. Flatten in-cell <ul>/<ol> lists to inline "• item" / "N. item" segments before pandoc runs, joined by a sentinel that post-processing restores to a literal <br>. Pandoc then produces a Markdown pipe table and GitHub renders line-broken bullets inside the cell. Cells without lists keep their existing space-joined behavior, so there is no regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Aqueeb Qadri <aqueeb@gmail.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Confluence exports place <th> cells inside <tbody> with no <thead>, so pandoc synthesized an empty header row and demoted the real header into the table body. Promote the first row into <thead> when it is built from <th> cells so pandoc emits a proper Markdown table header. Also fix a latent normalization bug where the "<th[^>]*>" attribute-stripping regex matched "<thead>" (which shares the "<th" prefix) and corrupted explicit table headers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Aqueeb Qadri <aqueeb@gmail.com>
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
Fixes #6 — Confluence tables whose cells contain a bullet/numbered list were left as raw HTML instead of a Markdown table.
Root cause: pandoc's GFM writer can only place inline, single-line content in pipe-table cells. When a cell holds block-level content (a
<ul>/<ol>list), pandoc can't express it as a pipe table and falls back to emitting the entire table as raw HTML. (Hard<br>breaks in a cell trigger the same fallback — which is why the existing code already strips them.)Fix: In
converter/markdown.go, flatten in-cell lists to inline• item/N. itemsegments before pandoc runs, joined by a@@C2MDBR@@sentinel.postProcessMarkdownrestores the sentinel to a literal<br>as its final step, so pandoc emits a clean pipe table and GitHub still renders line-broken bullets inside the cell. Cells without lists keep their existing space-joined behavior (no regression).Before
After
Tests
<br>.ConvertHTMLToMarkdowntest on the issue's exact table shape (asserts a pipe table, no<table>/<ul>).go test ./...passes;gofmt/go vetclean.testpage.doc.Limitation
Deeply nested sub-lists inside a cell flatten to a single bullet level (items preserved as text, no indentation) — acceptable for typical Confluence tables and noted in a code comment.
🤖 Generated with Claude Code