markdown-it-vue
markdown-it-vue copied to clipboard
markdown-it-vue 1.1.7版本 自定义了面板插件,自定义的插件js没有任何输出,这是为什么?
options: { html: true, // 在源码中启用 HTML 标签 markdownIt: { plugins: [customPanelPlugin], // 使用自定义插件 }, };
// customPanelPlugin.js export default function customPanelPlugin(md) { console.log('Custom panel plugin initialized md', md); // 调试日志 md.use(require('markdown-it-container'), 'panel', { validate: function (params) { console.log('Validate params:', params); // 调试输出 return params.trim().split(' ')[0] === 'panel'; }, render: function (tokens, idx) { console.log('Render token:', tokens[idx]); // 调试输出 const token = tokens[idx]; const params = token.info.trim().split(' '); const type = params[1] || 'default'; // 获取面板类型
if (token.nesting === 1) {
return `<div class="custom-panel custom-panel-${type}">\n`;
}
return '</div>\n';
},
});
}