Closed Richard-Choooou closed 11 months ago
I tryed to modify the token list
render: (tokens, idx) => {
if (tokens[idx].nesting === 1) {
const config = tokens[idx + 2]
for (let i = 0; i < 3; i++) {
tokens.splice(idx + 3 - i, 1)
}
return `<div>
<echarts-render echartsConfig="${config.content}"></echarts-render>
`;
} else {
return '</div>';
}
}
the well be throw error like this.
./docs/line-charts.md
Module build failed (from ./node_modules/@vuepress/markdown-loader/index.js):
TypeError: Cannot read properties of undefined (reading 'type')
at Renderer.render (C:\Users\zhoup\Desktop\project\front-end\cateyes-charts\node_modules\markdown-it\lib\renderer.js:321:22)
at MarkdownIt.render (C:\Users\zhoup\Desktop\project\front-end\cateyes-charts\node_modules\markdown-it\lib\index.js:543:24)
at MarkdownIt.md.render (C:\Users\zhoup\Desktop\project\front-end\cateyes-charts\node_modules\@vuepress\markdown\index.js:142:25)
at Object.module.exports (C:\Users\zhoup\Desktop\project\front-end\cateyes-charts\node_modules\@vuepress\markdown-loader\index.js:74:16)
can use a html comment tag:
if (tokens[idx].nesting === 1) {
return `<div><!--`;
} else {
return '--></div>';
}
same like.
before:
after render:
without the raw content