Skip to content

Commit 770f95b

Browse files
committed
fix: restore readme heading anchors for inline code
1 parent dd90132 commit 770f95b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

server/utils/readme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const ALLOWED_ATTR: Record<string, string[]> = {
210210
* - Collapse multiple hyphens
211211
*/
212212
function slugify(text: string): string {
213-
return stripHtmlTags(text)
213+
return decodeHtmlEntities(stripHtmlTags(text))
214214
.toLowerCase()
215215
.trim()
216216
.replace(/\s+/g, '-') // Spaces to hyphens

test/unit/server/utils/readme.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,12 @@ describe('HTML output', () => {
597597
const result = await renderReadmeHtml(markdown, 'test-pkg')
598598

599599
expect(result.toc).toHaveLength(2)
600-
expect(result.toc[0]).toMatchObject({ text: '<Text>', id: 'user-content-lttextgt', depth: 3 })
601-
expect(result.toc[1]).toMatchObject({ text: '<Box>', id: 'user-content-ltboxgt', depth: 3 })
600+
expect(result.toc[0]).toMatchObject({ text: '<Text>', id: 'user-content-text', depth: 3 })
601+
expect(result.toc[1]).toMatchObject({ text: '<Box>', id: 'user-content-box', depth: 3 })
602602
expect(result.html).toContain('<code>&lt;Text&gt;</code>')
603603
expect(result.html).toContain('<code>&lt;Box&gt;</code>')
604-
expect(result.html).toContain('id="user-content-lttextgt"')
605-
expect(result.html).toContain('id="user-content-ltboxgt"')
604+
expect(result.html).toContain('id="user-content-text"')
605+
expect(result.html).toContain('id="user-content-box')
606606
expect(result.html).not.toContain('user-content-heading')
607607
})
608608

@@ -837,7 +837,7 @@ describe('Issue #1323 — single-pass rendering correctness', () => {
837837
expect(result.html).toContain('<p>Paragraph before code.</p>')
838838
expect(result.html).toContain('const component = "Text"')
839839
expect(result.html).toContain('<p>Paragraph after code.</p>')
840-
expect(result.html).toContain('id="user-content-lttextgt"')
840+
expect(result.html).toContain('id="user-content-text"')
841841
})
842842
})
843843
})

0 commit comments

Comments
 (0)