fix(ios): preserve code block styles inside list items#174
Merged
hryhoriiK97 merged 2 commits intosoftware-mansion-labs:mainfrom Mar 28, 2026
Merged
Conversation
When a fenced code block appears inside a list item, ListItemRenderer's paragraph style enumeration was overwriting the code block's own styles (padding, LTR indent) with list item styles. This caused code block content to display list markers (e.g. "2.") on every line. Skip ranges that have the CodeBlockAttributeName attribute, since CodeBlockRenderer has already applied the correct paragraph style. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hryhoriiK97
requested changes
Mar 23, 2026
Collaborator
hryhoriiK97
left a comment
There was a problem hiding this comment.
@Mile-Away thank you for the PR with fix! One thing which should be covered - he same pattern exists in applyCheckedDecorationsTo:range:nestingLevel.
Please add the same guard there as well:
[output enumerateAttribute:ListDepthAttribute
inRange:range
options:0
usingBlock:^(NSNumber *depth, NSRange segmentRange, BOOL *stop) {
BOOL isNestedSubItem = (depth && [depth integerValue] > nestingLevel);
if (isNestedSubItem) {
return;
}
NSNumber *isCodeBlock = [output attribute:CodeBlockAttributeName
atIndex:segmentRange.location
effectiveRange:nil];
if ([isCodeBlock boolValue]) {
return;
}
[output addAttributes:checkedAttrs range:segmentRange];
}];
Add the same CodeBlockAttributeName check to applyCheckedDecorationsTo so that checked task list strikethrough/color styles don't bleed into code block ranges inside list items. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hryhoriiK97
approved these changes
Mar 28, 2026
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
When a fenced code block appears inside a list item (e.g.
```textinside an ordered list),ListItemRenderer's paragraph style enumeration overwrites the code block's own styles with list item styles. This causes:Root cause:
ListItemRenderer.menumeratesListDepthAttributeover the entire item range and applies list paragraph styles to all segments that don't belong to a nested sub-list. Code block ranges (which haveCodeBlockAttributeNameset byCodeBlockRenderer) were not excluded.Fix: Check for
CodeBlockAttributeNamein the enumeration callback and skip those ranges, preserving the paragraph style already applied byCodeBlockRenderer.Reproduction
Before this fix, lines inside the code block render with "2." list markers on iOS.
Test plan
🤖 Generated with Claude Code