fix: stuff
This commit is contained in:
+23
-2
@@ -1,8 +1,29 @@
|
||||
import { Marked } from 'marked';
|
||||
import { createDirectives } from 'marked-directive';
|
||||
import {createDirectives, presetDirectiveConfigs} from 'marked-directive';
|
||||
|
||||
// 使用 marked-directive 来支持指令语法
|
||||
const marked = new Marked().use(createDirectives());
|
||||
const marked = new Marked().use(createDirectives([
|
||||
...presetDirectiveConfigs,
|
||||
{
|
||||
marker: '::::',
|
||||
level: 'container'
|
||||
},
|
||||
{
|
||||
marker: ':::::',
|
||||
level: 'container'
|
||||
},
|
||||
{
|
||||
level: 'inline',
|
||||
marker: ':',
|
||||
// :[blah] becomes <i class="icon icon-blah"></i>
|
||||
renderer(token) {
|
||||
if (!token.meta.name) {
|
||||
return `<icon class="icon-${token.text}"></icon>`;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
]));
|
||||
|
||||
export function parseMarkdown(content: string): string {
|
||||
return marked.parse(content.trimStart()) as string;
|
||||
|
||||
Reference in New Issue
Block a user