Skip to content

fix(convert): pass through <br> in markdown so table cells can have line breaks#209

Open
devlimits wants to merge 1 commit into
pchuri:mainfrom
devlimits:fix/br-cell-passthrough
Open

fix(convert): pass through <br> in markdown so table cells can have line breaks#209
devlimits wants to merge 1 commit into
pchuri:mainfrom
devlimits:fix/br-cell-passthrough

Conversation

@devlimits

Copy link
Copy Markdown
Contributor

Summary

  • Add br to the inline-HTML passthrough allow-list in MacroConverter, so <br> survives markdown→storage conversion instead of being escaped to &lt;br&gt;.
  • <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 of create / update) runs markdown-it with html: 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 — but br was missing from that list.

As a result a table cell could not contain a line break. | v1 | 가<br>나<br>다 | produced <td><p>가&lt;br&gt;나&lt;br&gt;다</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. With br added, the same input now yields <td><p>가<br>나<br>다</p></td>.

Behavior preservation

  • False positives still rejected — the (?=[\s/>]) lookahead keeps <broken> and autolink-shaped <br:foo> out of the allow-list.
  • Real escaping unchanged — only allow-listed tags are stashed; <, &, and non-listed tags (e.g. <script>) are still escaped.
  • Code regions unaffected<br> inside inline / fenced / indented code stays escaped as literal text via the existing code-range exclusion.

Test plan

  • New tests in tests/macro-converter.test.js: <br> in a table cell passes through; <br/> / <br /> variants pass through; <br> inside inline code stays escaped.
  • Full suite green (692 tests).

Out of scope

  • The reverse direction (storage→markdown) already renders a <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.

…ine breaks

markdown-it runs with html:false, so raw <br> was escaped to &lt;br&gt;
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant