This commit is contained in:
amehime
2020-05-04 14:27:42 +08:00
parent f398c7a1e5
commit 530b1bc8dd
3 changed files with 19 additions and 3 deletions

View File

@@ -0,0 +1,15 @@
module.exports = function (md, options) {
const defaultRenderer = md.renderer.rules.text.bind(md.renderer.rules)
const rExcerpt = /<!--+\s*more\s*--+>/i;
md.renderer.rules.text = (tokens, index, options, env, self) => {
const content = tokens[index].content
if (rExcerpt.test(content)) {
return content
} else {
return defaultRenderer(tokens, index, options, env, self)
}
}
}

View File

@@ -96,7 +96,7 @@ module.exports = function (md, options) {
result += `<figcaption>${caption}</figcaption>`;
}
result += `<pre>${code}`;
result += `<pre><code>${code}`;
if (config.line_number) {
result += `<span aria-hidden="true" class="line-numbers-rows" data-first="${Number(firstLine)}">${numbers}</span>`;
@@ -107,7 +107,7 @@ module.exports = function (md, options) {
}
result += '</pre></figure>';
result += '</code></pre></figure>';
return result;
} else {

View File

@@ -16,7 +16,8 @@ const default_plugins = [
'markdown-it-toc-and-anchor',
'markdown-it-pangu',
'./markdown-it-mermaid',
'./markdown-it-prism'
'./markdown-it-prism',
'./markdown-it-excerpt'
];
/**