fix(convert): render a block inside a list item as a block - #212
Merged
Merged
Conversation
read/export sent every <li> child other than a <p> or a nested list through renderInline. A code macro there rendered its fence onto the item's text line, where it is not a fence, and its unindented body ended the list. The editor writes exactly that shape for a code block added to a list item. A table, a quote, a callout or a <pre> in a list item was flattened into the item's text the same way. A block now renders indented under the item, in document order. A fence needs no blank line on either side, so an item with text and a code block stays tight and publishes back to the storage it came from. Every other block is set off by a blank line, which it needs. Fixes #211.
A fence was tight beside any block, but a raw HTML table runs until a blank line and swallowed a fence right after it. A fence is now tight only beside text, another fence or a nested list. Nested lists were still collected and written after everything else, so one before a code block moved below it. They now render in document order like every other child, and text after one is set off by a blank line, which it needs or it continues the list's last item. An <hr> is no longer a block: "- ---" is a thematic break rather than an item, and the editor offers no divider in a list. Loose inline children render as one run through renderInlineChildren, so text after a <br /> no longer gains a space on every round trip, and a mark split around a link is repaired as it is in a <p>. Every segment, the first included, is indented the same way, and a fence is decided by the node rather than by the 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.
Fixes #211.
read/exportsent every<li>child other than a<p>or a nested list throughrenderInline, so a code macro in a list item came out with its opening fence on the item's text line and its body unindented. The Confluence editor writes exactly that shape (<li>text<ac:structured-macro ac:name="code">…</li>), and SREIN Triage and Work Process has two of them. This is older than the line-break/paragraph work:renderListItemwas unchanged from v0.1.0 until this PR.What changes
<pre>, table, quote, callout or heading inside a list item now renders as a block indented under the item. Nested lists and blocks keep their document order.renderInlineChildren. Text after a<br />no longer gains a space on every round trip, and a mark split around a link is repaired the way it already is in a<p>.<hr>is deliberately not handled as a block.- ---is a thematic break, not a list item, and the editor has no way to put a divider in a list.Testing
testdata/storage2md/list-blockscase covering the SREIN shape, the editor's<p>form, text after a block, an item that is only a code block, nested lists before and after blocks, a raw table followed by a fence, callouts, quotes, tables, and an inline status macro that must stay inline. Being a storage2md case, it also runs throughTestRoundTripMarkdownIsAFixedPointand the output-parses-as-Markdown check.check --show-htmlon the new export reproduces the page's original<li>text<ac:structured-macro …>storage.make checkpasses.Review findings left out (older, not caused by this change)
-,#) is read back as that block. This is the read: paragraph text that looks like a Markdown block becomes structure on publish #203 class, now also reachable inside a list item.<p>still goes through the inline path. Confluence doesn't write that shape.<p>around their text. This is CommonMark's rule, and the Markdown is still a fixed point.<p>s in one item are still joined with a space.