mirror of
https://github.com/amehime/hexo-renderer-multi-markdown-it.git
synced 2026-04-05 04:59:04 +08:00
add collapse
This commit is contained in:
@@ -137,7 +137,6 @@ prismjs:
|
||||
- [markdown-it-toc-and-anchor](https://www.npmjs.com/package/markdown-it-toc-and-anchor)
|
||||
- [markdown-it-container](https://www.npmjs.com/package/markdown-it-container)
|
||||
- [markdown-it-multimd-table](https://www.npmjs.com/package/markdown-it-multimd-table)
|
||||
- [markdown-it-collapsible](https://www.npmjs.com/package/markdown-it-collapsible)
|
||||
- [markdown-it-katex](https://www.npmjs.com/package/@neilsustc/markdown-it-katex)
|
||||
|
||||
If you want to use katex, you must add this css style to your website:
|
||||
|
||||
@@ -13,7 +13,6 @@ const default_plugins = [
|
||||
'markdown-it-sup',
|
||||
'markdown-it-task-checkbox',
|
||||
'markdown-it-toc-and-anchor',
|
||||
'markdown-it-collapsible',
|
||||
'markdown-it-pangu',
|
||||
'./markdown-it-container',
|
||||
'./markdown-it-furigana',
|
||||
|
||||
@@ -4,14 +4,14 @@ module.exports = function (md, options) {
|
||||
|
||||
md.use(plugin, 'note', {
|
||||
validate: function (params) {
|
||||
return params.trim().match(/^note\s+(default|primary|success|info|warning|danger)$/);
|
||||
return params.trim().match(/^(default|primary|success|info|warning|danger)(.*)$/);
|
||||
},
|
||||
render: function (tokens, idx) {
|
||||
var m = tokens[idx].info.trim().match(/^note\s+(.*)$/);
|
||||
var m = tokens[idx].info.trim().match(/^(.*)$/);
|
||||
|
||||
if (tokens[idx].nesting === 1) {
|
||||
// opening tag
|
||||
return '<div class="note ' + m[1] + '">\n';
|
||||
return '<div class="note ' + m[1].trim() + '">\n';
|
||||
|
||||
} else {
|
||||
// closing tag
|
||||
@@ -24,11 +24,11 @@ module.exports = function (md, options) {
|
||||
marker: ';',
|
||||
|
||||
validate: function(params) {
|
||||
return params.trim().match(/^tab\s+(.*)\|\|(.*)$/);
|
||||
return params.trim().match(/^(\w+)+(.*)$/);
|
||||
},
|
||||
|
||||
render: function (tokens, idx) {
|
||||
var m = tokens[idx].info.trim().match(/^tab\s+(.*)\|\|(.*)$/);
|
||||
var m = tokens[idx].info.trim().match(/^(\w+)+(.*)$/);
|
||||
|
||||
if (tokens[idx].nesting === 1) {
|
||||
// opening tag
|
||||
@@ -40,4 +40,25 @@ module.exports = function (md, options) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
md.use(plugin, 'collapse', {
|
||||
marker: '+',
|
||||
|
||||
validate: function(params) {
|
||||
return params.match(/^(primary|success|info|warning|danger|\s)(.*)$/);
|
||||
},
|
||||
|
||||
render: function (tokens, idx) {
|
||||
var m = tokens[idx].info.match(/^(primary|success|info|warning|danger|\s)(.*)$/);
|
||||
|
||||
if (tokens[idx].nesting === 1) {
|
||||
// opening tag
|
||||
var style = m[1].trim()
|
||||
return '<details' + (style ? ' class="'+style+'"' : '') +'><summary>'+m[2].trim()+'</summary><div>\n';
|
||||
} else {
|
||||
// closing tag
|
||||
return '</div></details>\n';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexo-renderer-multi-markdown-it",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "A Markdown parser for Hexo and auto Minify HTML, CSS, JS.",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/amehime/hexo-renderer-multi-markdown-it.git",
|
||||
@@ -34,7 +34,6 @@
|
||||
"markdown-it-attrs": "^3.0.2",
|
||||
"markdown-it-bracketed-spans": "^1.0.1",
|
||||
"markdown-it-charts": "^1.0.5",
|
||||
"markdown-it-collapsible": "^1.0.0",
|
||||
"markdown-it-container": "^2.0.0",
|
||||
"markdown-it-deflist": "^2.0.3",
|
||||
"markdown-it-emoji": "^1.4.0",
|
||||
|
||||
Reference in New Issue
Block a user