Skip to content

Commit 7927e7a

Browse files
yyq1025claude
andcommitted
app: patch enriched — ordered lists honor GFM start numbers
enriched ignores ordered-list start numbers end to end: the cpp parser discards MD_BLOCK_OL_DETAIL.start (never reaches the AST) and the iOS ListRenderer unconditionally resets its counter to 0 — so the list-hoist continuation runs ("2. …", "3. …") all rendered as 1. Upstream main (checked 2026-06-12) has neither a fix nor an in-flight PR. pnpm patch: the parser stores a "start" node attribute when != 1 (the ObjC bridge copies attributes generically), and ListRenderer seeds listItemNumber = start - 1 (ListItemRenderer pre-increments). NATIVE change — effective from the next dev-client build. Android has the same gap (BlockStyleContext.kt); left for the upstream PR, which should carry both platforms. The lockfile also records the @pierre/theme / @expo-google-fonts / @shikijs/themes dependency moves from the previous commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 75e0c5b commit 7927e7a

3 files changed

Lines changed: 79 additions & 13 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/cpp/parser/MD4CParser.cpp b/cpp/parser/MD4CParser.cpp
2+
index ebcde8b905dade9c93023c3ffad36e324ba55d16..8d967b85c3580af3058c59f302f2e4c296c51d8a 100644
3+
--- a/cpp/parser/MD4CParser.cpp
4+
+++ b/cpp/parser/MD4CParser.cpp
5+
@@ -19,6 +19,7 @@ public:
6+
static const std::string ATTR_LANGUAGE;
7+
static const std::string ATTR_IS_TASK;
8+
static const std::string ATTR_TASK_CHECKED;
9+
+ static const std::string ATTR_START;
10+
11+
void reset(size_t estimatedDepth) {
12+
root = std::make_shared<MarkdownASTNode>(NodeType::Document);
13+
@@ -114,7 +115,17 @@ public:
14+
}
15+
16+
case MD_BLOCK_OL: {
17+
- impl->pushNode(std::make_shared<MarkdownASTNode>(NodeType::OrderedList));
18+
+ auto node = std::make_shared<MarkdownASTNode>(NodeType::OrderedList);
19+
+ if (detail) {
20+
+ // GFM: an ordered list starts at its first item's literal number
21+
+ // ("3. foo" renders 3, 4, …). md4c reports it; without this the
22+
+ // renderers restart every list at 1.
23+
+ auto *ol = static_cast<MD_BLOCK_OL_DETAIL *>(detail);
24+
+ if (ol->start != 1) {
25+
+ node->setAttribute(ATTR_START, std::to_string(ol->start));
26+
+ }
27+
+ }
28+
+ impl->pushNode(node);
29+
break;
30+
}
31+
32+
@@ -527,5 +538,6 @@ const std::string MD4CParser::Impl::ATTR_FENCE_CHAR = "fenceChar";
33+
const std::string MD4CParser::Impl::ATTR_LANGUAGE = "language";
34+
const std::string MD4CParser::Impl::ATTR_IS_TASK = "isTask";
35+
const std::string MD4CParser::Impl::ATTR_TASK_CHECKED = "taskChecked";
36+
+const std::string MD4CParser::Impl::ATTR_START = "start";
37+
38+
} // namespace Markdown
39+
\ No newline at end of file
40+
diff --git a/ios/renderer/ListRenderer.m b/ios/renderer/ListRenderer.m
41+
index 6927b4b297e634bb034b3d72eaadb4921edfef7a..344128e054cf5967da84a01af79cac0ffb51aea1 100644
42+
--- a/ios/renderer/ListRenderer.m
43+
+++ b/ios/renderer/ListRenderer.m
44+
@@ -44,7 +44,16 @@ - (void)renderNode:(MarkdownASTNode *)node into:(NSMutableAttributedString *)out
45+
46+
context.listDepth = prevDepth + 1;
47+
context.listType = _isOrdered ? ListTypeOrdered : ListTypeUnordered;
48+
- context.listItemNumber = 0; // Reset counter for this specific list level
49+
+ // Reset counter for this specific list level. Ordered lists honor the
50+
+ // GFM start number ("3. foo" renders 3, 4, …) — the parser puts it on
51+
+ // the node only when != 1; ListItemRenderer pre-increments, so the
52+
+ // counter starts one below the first rendered number.
53+
+ NSInteger startNumber = 1;
54+
+ NSString *startAttr = node.attributes[@"start"];
55+
+ if (_isOrdered && startAttr != nil) {
56+
+ startNumber = MAX((NSInteger)1, (NSInteger)startAttr.integerValue);
57+
+ }
58+
+ context.listItemNumber = startNumber - 1;
59+
60+
[context setBlockStyle:_isOrdered ? BlockTypeOrderedList : BlockTypeUnorderedList
61+
font:_config.listStyleFont

pnpm-lock.yaml

Lines changed: 16 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ allowBuilds:
1616
sharp: true
1717
workerd: true
1818
nodeLinker: hoisted
19+
patchedDependencies:
20+
react-native-enriched-markdown: patches/react-native-enriched-markdown.patch

0 commit comments

Comments
 (0)