fix(convert): pass through <br> in markdown so table cells can have line breaks#209
Open
devlimits wants to merge 1 commit into
Open
fix(convert): pass through <br> in markdown so table cells can have line breaks#209devlimits wants to merge 1 commit into
devlimits wants to merge 1 commit into
Conversation
…ine breaks markdown-it runs with html:false, so raw <br> was escaped to <br> and cells could not contain a line break. Add br to the inline-HTML passthrough allow-list; <br>, <br/>, <br /> now survive, while <br> in code spans stays escaped.
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
brto the inline-HTML passthrough allow-list inMacroConverter, so<br>survives markdown→storage conversion instead of being escaped to<br>.<br>,<br/>, and<br />all pass through; a<br>inside a code span/block stays escaped as literal text.Why
confluence convert --input-format markdown --output-format storage(and the markdown input path ofcreate/update) runs markdown-it withhtml: false, so all raw inline HTML is escaped. The converter works around this by stashing an allow-listed set of inline tags (u,sub,sup,mark,details,summary) around the render and restoring them afterward — butbrwas missing from that list.As a result a table cell could not contain a line break.
| v1 | 가<br>나<br>다 |produced<td><p>가<br>나<br>다</p></td>. This is the practical way to get a line break inside a table cell, since markdown table grammar allows only inline text per cell. Withbradded, the same input now yields<td><p>가<br>나<br>다</p></td>.Behavior preservation
(?=[\s/>])lookahead keeps<broken>and autolink-shaped<br:foo>out of the allow-list.<,&, and non-listed tags (e.g.<script>) are still escaped.<br>inside inline / fenced / indented code stays escaped as literal text via the existing code-range exclusion.Test plan
tests/macro-converter.test.js:<br>in a table cell passes through;<br/>/<br />variants pass through;<br>inside inline code stays escaped.Out of scope
<br>node as\n, so round-tripping a<br>back out of a table cell hits a separate, pre-existing markdown-grammar limitation. This PR only fixes the forward (authoring) direction.