fix(storage-walker): preserve nested task lists in storage → markdown - #245
Merged
Merged
Conversation
A task list nested inside <ac:task-body> was collapsed onto the parent task's line, and a nested <ac:task-list> written as a sibling of its parent <ac:task> (the Confluence Cloud editor form) was dropped entirely. Both forms now render as indented children of the parent task, reusing the list-item body renderer and LIST_INDENT sentinel from #239. Task bodies are rendered as blocks like <li> bodies, so code macros, paragraphs and regular lists inside a task keep their structure. A task whose body starts with a block keeps a bare checkbox on the marker line. Adjacent nested lists in one item are now joined tightly. Fixes #240
…lock Only put a task checkbox on its own line when the following block can interrupt a paragraph (fence, heading, quote, table, HTML, list or thematic break). Bodies starting with <pre> or an expand macro keep the checkbox inline, as before. A plain <li> holding a bare `[ ]` followed by such a block, which is what markdown -> storage produces for that output, now renders the same way, so the round-trip is stable. Add round-trip tests for each first-block kind, tests for the tight join of adjacent lists and the sentinel leak inside <p> on ordinary lists, and a Confluence Cloud-shaped nested task sample to parity fixture 08.
# Conflicts: # lib/storage-walker.js
|
🎉 This PR is included in version 2.25.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
9 of 15 tasks
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 #240
Pull Request Template
Description
Storage → markdown conversion now preserves nested task lists. There are two storage forms:
<ac:task-body>: this is the form in the issue. It used to be collapsed onto the parent line (- [ ] Parent - [x] Child).<ac:task>: this is what the Confluence Cloud editor writes (for example, marked-space's documented editor output). These nested tasks used to be dropped entirely.Both forms now render as indented children of the parent task:
Implementation (
lib/storage-walker.js):handleTaskListgroups each sibling<ac:task-list>under the preceding<ac:task>. The task body is then rendered with the samerenderListItemBody()andLIST_INDENTpath that fix(storage-walker): preserve nested list structure in storage → markdown (#238) #239 added for<li>.handleListmoves into a sharedformatListItem()helper. This is not a behavior change.renderListItemBody()gets an optionalcheckboxargument:<pre>or an expand macro, which render as paragraph text.[ ]as a checkbox when it is not a paragraph of its own. A leading---becomes***so it doesn't turn into a setext heading.<li>with[ ](as text or<p>) followed by the block. That shape renders the same way on the way back, so the round-trip is stable. A bare[ ]followed by ordinary text in a plain<li>is left alone.Side effects, found and fixed during review:
<p>in a list item no longer leaks sentinel spaces. This was already an issue onmainfor<ul>inside<p>.Both side effects also apply to ordinary lists and have their own tests.
Behavior change: task bodies are now rendered as blocks instead of one flattened line. Code macros, multiple paragraphs, and regular lists inside a task keep their structure. Inline-only bodies are unchanged, including whitespace collapsing. Task lists inside table cells are still flattened to one line.
Round-trip: markdown → storage still emits plain
<ul><li>[ ] …</li></ul>, since writing tasks back to Confluence is out of scope. A task-list storage → markdown → storage → markdown round-trip is stable. Tests cover nested tasks and every first-block kind (code, pre, heading, table, blockquote, info, hr, list, task list), in both tight and loose items.Known limitation (with #246's
<ol start>support): a bare checkbox followed by an ordered list that starts at a number other than 1 renders as- [ ]\n 3. c. GFM doesn't let such a list interrupt a paragraph, so it merges into the[ ]line. This is rare and not handled here, because every alternative loses either the checkbox or the list.Type of Change
Testing
New exact-output (
toBe) tests are in thenested task listsblock oftests/macro-converter.test.js. They cover:<hr><p>08-lists-and-tasks: the sibling form withac:task-id, theplaceholder-inline-tasksspan, and pretty-printed whitespacenpx jest(1403 tests, on currentmainincluding #246–#250) andnpx eslint lib testsboth pass.Checklist
Screenshots (if applicable)
N/A
Additional Context
Follow-up to #238 / #239. No documentation changes are needed. The changelog is generated by semantic-release.