Skip to content

Commit

Permalink
fix(md): fix some markdown rendering issues (#2862)
Browse files Browse the repository at this point in the history
* fix(md): correctly append feedback on linked headings

* fix(md): make sure to use vitepress' default link renderer
  • Loading branch information
rhld16 authored Jan 19, 2025
1 parent 6d6b4ab commit 9fd6157
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/.vitepress/markdown/headers.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export const headersPlugin = (md: MarkdownRenderer) => {
//
// The token after `heading_open` contains the link as a child token.
const children = tokens[idx + 1].children || []
const linkOpenToken = children.find((c) => c.type === 'link_open')
const linkOpenToken = children.findLast((c) => c.type === 'link_open')
if (!linkOpenToken) return result

const heading = tokens[idxClose - 1]
@@ -53,8 +53,10 @@ export const headersPlugin = (md: MarkdownRenderer) => {
return result
}

let defaultRender = md.renderer.rules.link_open;

md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
const result = self.renderToken(tokens, idx, options)
const result = defaultRender(tokens, idx, options, env, self);

const meta = tokens[idx].meta
if (!meta || !meta.feedback) return result

0 comments on commit 9fd6157

Please sign in to comment.