Skip to content

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

Merged
pchuri merged 1 commit into
pchuri:mainfrom
devlimits:fix/br-cell-passthrough
Jul 6, 2026
Merged

fix(convert): pass through <br> in markdown so table cells can have line breaks#209
pchuri merged 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.
@pchuri

pchuri commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution, @devlimits! This is a clean, well-scoped fix — adding br to the inline passthrough allow-list is exactly the right approach, and it addresses the table-cell line-break case that markdown table grammar can't otherwise express. The added tests (table cell, <br/> / <br /> variants, and the inline-code exclusion) cover the behavior well, and CI is green across Node 18/20/22.

We'll approve this and get it merged. Thanks again!

@pchuri pchuri self-requested a review July 6, 2026 07:01
@pchuri pchuri merged commit ae811e4 into pchuri:main Jul 6, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 6, 2026
## [2.15.1](v2.15.0...v2.15.1) (2026-07-06)

### Bug Fixes

* **convert:** pass through <br> in markdown so table cells can have line breaks ([#209](#209)) ([ae811e4](ae811e4))
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants