Repository navigation
Conversation
Port of the code block part of the React Native fix for list items with block children (#478): - The list item no longer trims the newlines its children leave, so a code block that ends an item keeps its bottom padding and rounded corners. - The item's list spans are split around its code blocks, and the code block draws its box from the item's text column (CodeBlockSpan.leadingIndent) instead of the left edge. Only the first segment draws the marker. - Task toggling flips every segment of a split item, and HTML and accessibility output stay consistent with the split spans. - Copy-as-markdown nests a code block under its item (CodeBlockSpan.listItem): the fences and code lines are indented to the item's text column, an item that opens with a code block puts its marker on the opening fence, and text after the block continues the item instead of starting a new one.
This was referenced Oct 23, 2026
jnowakow
requested review from
hryhoriiK97
and
a balanced review from Copilot
October 23, 2026 07:44
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved marker-rendering, right-to-left background, and HTML block-boundary regressions affect correctness.
3 open issues
What changed in this PR
Ports the code-block portion of #478 to standalone Android, aiming to keep code-block backgrounds inside list items and preserve bottom padding and rounded corners.
Changes:
- Tracks list indentation and splits list styling around code blocks.
- Updates task interaction, exports, and accessibility for split list items.
- Adds rendering, export, and task-toggle regression tests.
Paths below are relative to packages/enriched-markdown-android/ui/src/.
| File | Description |
|---|---|
test/java/com/swmansion/enriched/markdown/test/MarkdownRenderTestSupport.kt |
Adds combined list and code-block style helpers. |
test/java/com/swmansion/enriched/markdown/test/ListMarkerCanvas.kt |
Filters non-marker rectangles from recordings. |
test/java/com/swmansion/enriched/markdown/TaskListInteractionTest.kt |
Tests task toggling around code blocks. |
test/java/com/swmansion/enriched/markdown/ListChildrenRenderingTest.kt |
Tests list-child geometry and decorations. |
test/java/com/swmansion/enriched/markdown/ListChildrenExportTest.kt |
Tests Markdown, HTML, and accessibility output. |
main/java/com/swmansion/enriched/markdown/utils/text/interaction/TaskListTapUtils.kt |
Updates all segments of a task item. |
main/java/com/swmansion/enriched/markdown/utils/text/conversion/MarkdownExtractor.kt |
Preserves list indentation around code fences. |
main/java/com/swmansion/enriched/markdown/utils/text/conversion/HTMLGenerator.kt |
Skips empty bottom-margin paragraphs. |
main/java/com/swmansion/enriched/markdown/spans/UnorderedListSpan.kt |
Supports marker-free continuation spans. |
main/java/com/swmansion/enriched/markdown/spans/TaskListSpan.kt |
Supports checkbox-free continuation spans. |
main/java/com/swmansion/enriched/markdown/spans/OrderedListSpan.kt |
Supports number-free continuation spans. |
main/java/com/swmansion/enriched/markdown/spans/CodeBlockSpan.kt |
Adds list indentation and item metadata. |
main/java/com/swmansion/enriched/markdown/spans/BaseListSpan.kt |
Controls marker ownership. |
main/java/com/swmansion/enriched/markdown/renderer/ListItemRenderer.kt |
Splits list spans around code blocks. |
main/java/com/swmansion/enriched/markdown/renderer/HeadingRenderer.kt |
Ensures headings start on a new line. |
main/java/com/swmansion/enriched/markdown/renderer/CodeBlockRenderer.kt |
Applies accumulated indentation to code blocks. |
main/java/com/swmansion/enriched/markdown/renderer/BlockStyleContext.kt |
Tracks accumulated list indentation. |
main/java/com/swmansion/enriched/markdown/renderer/BlockquoteRenderer.kt |
Ensures quotes start on a new line. |
main/java/com/swmansion/enriched/markdown/accessibility/MarkdownAccessibilityHelper.kt |
Avoids announcing continuation segments as new items. |
Review effort: Balanced
Comment on lines
+141
to
+144
| if (segmentStart < itemEnd) { | ||
| builder.setSpan( | ||
| if (isFirstSegment) markerSpan else makeSpan(drawsMarker = false), | ||
| segmentStart, |
|
|
||
| rect.set( | ||
| left.toFloat() + inset, | ||
| left.toFloat() + leadingIndent + inset, |
Collaborator
Author
There was a problem hiding this comment.
It will be handled in the follow-up
| } | ||
|
|
||
| // A block's bottom-margin line inside a list item or a quote holds no content of its own. | ||
| if (paraText.isEmpty() && text.getSpans(para.start, para.start + 1, MarginBottomSpan::class.java).isNotEmpty()) return |
Collaborator
Author
There was a problem hiding this comment.
It will be handled in follow-up PR
This branch has not been deployed
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.

What/Why?
Port of the code block part of the React Native fix for list items with block children (#478). Before, a code block inside a list item drew its box from the left edge, under the item's marker, and a code block that ended an item lost its bottom padding and rounded corners.
Testing
PR Checklist