fix(convert): pass through a list inside a table cell instead of mangling it - #117
Merged
Conversation
Fixed in #113 but never written up: a table cell that needs more than one line uses a literal <br>, since a GFM table row has to stay on one physical line and a real newline isn't an option.
…ling it Found while writing README documentation for using <ul>/<ol>/<li> directly in a table cell (a real markdown list needs one line per item, which a GFM table row can't do). The write side already handles it -- goldmark's raw HTML passthrough carries the tags into storage unchanged -- but renderCellLines (added for #113) only special-cased <p> as a block boundary; a <ul>/<ol> fell into the inline "run" bucket and rendered as plain inline content with no separator between items at all. "<ul><li>one</li><li>two</li></ul>" exported as "onetwo". renderCellLines now treats <ul>/<ol> as their own line too, passed through as raw serialized tags rather than converted -- the same approach already used elsewhere for content that can't be expressed as pure markdown. Fixes #115.
Code review found that cellTexts's blanket "|" -> "\|" escape -- needed so literal pipe text doesn't get read as a column boundary in the single-line row a cell becomes -- was also being applied to the <ul>/<ol> passthrough this fix added. A backslash has no escaping meaning inside a quoted HTML attribute, so a link's href containing a "|" inside a passed-through list came back corrupted with a literal backslash baked in, which republishing would make permanent. Moved the escape into renderCellLines itself, applied only to rendered <p>/inline text, never to serialize's raw output. The same root cause reaches a plain <a href> outside any list too, which predates this fix and is filed separately as #116 -- fixing that needs the escape to apply to a link's text and not its destination, which isn't reachable from cellTexts once the two are already merged into one rendered string.
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
<br>for multi-line table cells (fixed in read/export: a multi-line table cell loses its line breaks entirely #113, never written up in the README).<ul>/<ol>/<li>directly in a table cell (a real markdown list needs one line per item, which a GFM table row can't do), found the export side was actually broken: the write direction works fine, butrenderCellLines(added for read/export: a multi-line table cell loses its line breaks entirely #113) only special-cased<p>as a block boundary, so a<ul>/<ol>fell into the inline "run" bucket and rendered with no separator between items at all —<ul><li>one</li><li>two</li></ul>exported asonetwo.<ul>/<ol>as their own line too, passed through as raw serialized tags rather than converted (the same approach already used elsewhere for content that can't be expressed as pure markdown).cellTexts's blanket|→\|escape (needed so literal pipe text doesn't get read as a column boundary) against the new raw-HTML passthrough corrupted a link'shrefcontaining a|— a backslash has no escaping meaning inside a quoted attribute. Fixed by moving the escape intorenderCellLines, applied only to rendered text, never toserialize's raw output.<a href>link outside any list (pre-existing, unrelated to this fix) — filed separately as read/export: a literal pipe in a table cell link's URL gets corrupted #116 since fixing it needs a larger change (escaping a link's text apart from its destination).Fixes #115.
Test plan
TestStorageToMarkdownPassesThroughListsInCells(<ul>/<ol>passthrough, Confluence-editor<li><p>shape, pipe-in-href correctness, round-trip stability)make checkpasses (vet, fmt-check, test, build, lint)