refactor: moved plugins to own folders
This commit is contained in:
parent
a212df96dd
commit
63bd438e45
6 changed files with 235 additions and 223 deletions
17
lib/details/plugin.js
Normal file
17
lib/details/plugin.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const markdownItContainer = require("markdown-it-container");
|
||||
|
||||
const markdownItDetails = (md) => {
|
||||
md.use(markdownItContainer, 'details', {
|
||||
validate: (params) => params.trim().match(/^(.*)$/),
|
||||
render: (tokens, idx) => {
|
||||
const m = tokens[idx].info.trim().match(/^(.*)$/);
|
||||
if (tokens[idx].nesting === 1) {
|
||||
const title = md.utils.escapeHtml(m[1]);
|
||||
return `<details class="expandable">\n<summary>${title}</summary>\n`;
|
||||
}
|
||||
return '</details>\n';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = markdownItDetails;
|
||||
Loading…
Add table
Add a link
Reference in a new issue