Skip to content

Commit 36cf091

Browse files
committed
fix: escape back ticks in toc headings #18
Fixes #18
1 parent c2596d9 commit 36cf091

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/preprocessReadme.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ export function preprocessReadme(opts: Partial<PreprocessReadmeOptions>): Pick<P
120120

121121
if (id === "table-of-contents") return;
122122

123-
const text = node.children[0].raw;
123+
const text = node.children
124+
.flatMap((child: any) => (child.type === "Element" ? child.children : child))
125+
.filter((child: any) => child.type === "Text")
126+
.map((child: any) => child.raw)
127+
.join("");
124128

125129
if (text !== undefined) {
126130
if (prev === "h3") {

test/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ interface Interface {
8888
8989
[package.json](package.json)
9090
91+
## Rendering with `svelte:component`
92+
9193
## License
9294

9395
[MIT](../LICENSE)

0 commit comments

Comments
 (0)