mirror of
https://github.com/fmhy/edit.git
synced 2025-07-31 00:02:17 +10:00
fix(md): fix some markdown rendering issues (#2862)
* fix(md): correctly append feedback on linked headings * fix(md): make sure to use vitepress' default link renderer
This commit is contained in:
parent
6d6b4abe9f
commit
9fd6157ec9
1 changed files with 4 additions and 2 deletions
|
@ -40,7 +40,7 @@ export const headersPlugin = (md: MarkdownRenderer) => {
|
||||||
//
|
//
|
||||||
// The token after `heading_open` contains the link as a child token.
|
// The token after `heading_open` contains the link as a child token.
|
||||||
const children = tokens[idx + 1].children || []
|
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
|
if (!linkOpenToken) return result
|
||||||
|
|
||||||
const heading = tokens[idxClose - 1]
|
const heading = tokens[idxClose - 1]
|
||||||
|
@ -53,8 +53,10 @@ export const headersPlugin = (md: MarkdownRenderer) => {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let defaultRender = md.renderer.rules.link_open;
|
||||||
|
|
||||||
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
|
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
|
const meta = tokens[idx].meta
|
||||||
if (!meta || !meta.feedback) return result
|
if (!meta || !meta.feedback) return result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue