diff --git a/src/ReactParser.ts b/src/ReactParser.ts index e7c6761..a67e2f4 100644 --- a/src/ReactParser.ts +++ b/src/ReactParser.ts @@ -57,7 +57,7 @@ class ReactParser { return this.renderer.listItem(listItemChildren); }); - return this.renderer.list(children, token.ordered); + return this.renderer.list(children, token.ordered, token.ordered ? token.start : undefined); } case 'code': { diff --git a/src/ReactRenderer.ts b/src/ReactRenderer.ts index bc148d8..cd22340 100644 --- a/src/ReactRenderer.ts +++ b/src/ReactRenderer.ts @@ -95,8 +95,8 @@ class ReactRenderer { return this.#h('blockquote', children); } - list(children: ReactNode, ordered: boolean) { - return this.#h(ordered ? 'ol' : 'ul', children); + list(children: ReactNode, ordered: boolean, start: number | undefined) { + return this.#h(ordered ? 'ol' : 'ul', children, ordered && start !== 1 ? { start } : {}); } listItem(children: ReactNode[]) { diff --git a/tests/markdown.spec.ts b/tests/markdown.spec.ts index 1af0309..b7da56f 100644 --- a/tests/markdown.spec.ts +++ b/tests/markdown.spec.ts @@ -88,6 +88,11 @@ const cases = [ markdown: '1. option-1\n2. option-2', html: '<ol><li>option-1</li><li>option-2</li></ol>', }, + { + title: 'render ordered lists with different start value', + markdown: '2. option-2\n3. option-3', + html: '<ol start="2"><li>option-2</li><li>option-3</li></ol>', + }, { title: 'render codeblocks', markdown: '```\n<script>console.log("Hello")</script>\n```',