mirror of
https://github.com/amehime/hexo-renderer-multi-markdown-it.git
synced 2026-04-05 13:09:04 +08:00
update
This commit is contained in:
15
lib/markdown-it-excerpt/index.js
Normal file
15
lib/markdown-it-excerpt/index.js
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user