add 添加脚注支持 footnote
This commit is contained in:
parent
5d6f5cf38e
commit
cad0ac5221
@ -58,13 +58,6 @@ export class MarkdownParser {
|
|||||||
return token as any
|
return token as any
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
},
|
|
||||||
renderer(token: any) {
|
|
||||||
const footnoteStyle = (options?.inline?.footnote || {})
|
|
||||||
const styleStr = Object.entries(footnoteStyle)
|
|
||||||
.map(([key, value]) => `${key}:${value}`)
|
|
||||||
.join(';')
|
|
||||||
return `<sup${styleStr ? ` style="${styleStr}"` : ''}><a href="#fn-${token.text}">[${token.text}]</a></sup>`
|
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
@ -370,6 +370,13 @@ export class MarkdownRenderer {
|
|||||||
const styleStr = cssPropertiesToString(delStyle)
|
const styleStr = cssPropertiesToString(delStyle)
|
||||||
return `<del${styleStr ? ` style="${styleStr}"` : ''}>${text}</del>`
|
return `<del${styleStr ? ` style="${styleStr}"` : ''}>${text}</del>`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加脚注支持
|
||||||
|
this.renderer.footnote = (token: any) => {
|
||||||
|
const footnoteStyle = (this.options.inline?.footnote || {})
|
||||||
|
const styleStr = cssPropertiesToString(footnoteStyle)
|
||||||
|
return `<sup${styleStr ? ` style="${styleStr}"` : ''}><a href="#fn-${token.text}">[${token.text}]</a></sup>`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRenderer(): typeof marked.Renderer.prototype {
|
public getRenderer(): typeof marked.Renderer.prototype {
|
||||||
|
7
src/types/marked.d.ts
vendored
Normal file
7
src/types/marked.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { marked } from 'marked';
|
||||||
|
|
||||||
|
declare module 'marked' {
|
||||||
|
interface RendererThis {
|
||||||
|
footnote: (token: any) => string;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user