diff --git a/packages/md/src/theme/prose.css b/packages/md/src/theme/prose.css index 1f33919ef..86176892f 100644 --- a/packages/md/src/theme/prose.css +++ b/packages/md/src/theme/prose.css @@ -44,6 +44,7 @@ .void-md h4, .void-md h5, .void-md h6 { + position: relative; font-weight: 600; line-height: 1.3; margin-top: 1.5em; @@ -162,9 +163,10 @@ } /* Anchor links */ +/* Ends at the heading's start edge, so a wide "#" in any font never covers the text. */ .void-md .header-anchor { - float: inline-start; - margin-inline-start: -0.87em; + position: absolute; + inset-inline-end: 100%; padding-inline-end: 0.23em; font-weight: 500; opacity: 0; diff --git a/packages/md/test/integration/theme-layout.test.ts b/packages/md/test/integration/theme-layout.test.ts index 3f50a8039..f9990c0f3 100644 --- a/packages/md/test/integration/theme-layout.test.ts +++ b/packages/md/test/integration/theme-layout.test.ts @@ -14,7 +14,9 @@ beforeAll(async () => { const nested = await compile('- [ ] parent\n - [x] child\n - [ ] another child'); const loose = await compile('- [ ] first paragraph\n\n second paragraph\n\n- ordinary item'); const code = await compile('## Heading\n\n```js\nconst x = 1;\n```'); - html = `
+ // A wide "#" (as some fonts draw it) must still end before the heading text. + html = ` +
${nested.html}
${loose.html}
${code.html}