Added support for highlighted text and footnotes

This commit is contained in:
Ole Eskild Steensen 2022-03-10 13:59:21 +01:00
parent 6998e7af13
commit 2e9432181e
4 changed files with 92 additions and 68 deletions

View File

@ -7,7 +7,9 @@ module.exports = function(eleventyConfig) {
let markdownLib = markdownIt({
breaks: true,
html: true
}).use(function(md) {
})
.use(require("markdown-it-footnote"))
.use(function(md) {
//https://github.com/DCsunset/markdown-it-mermaid-plugin
const origFenceRule = md.renderer.rules.fence || function(tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options, env, self);
@ -99,6 +101,13 @@ module.exports = function(eleventyConfig) {
});
})
eleventyConfig.addTransform('highlight', function(str) {
//replace ==random text== with <mark>random text</mark>
return str && str.replace(/\=\=(.*?)\=\=/g, function(match, p1) {
return `<mark>${p1}</mark>`;
});
});
return {
dir: {
input: "src/site",

13
package-lock.json generated
View File

@ -14,7 +14,8 @@
"@sindresorhus/slugify": "^1.1.0",
"dotenv": "^10.0.0",
"gray-matter": "^4.0.3",
"markdown-it": "^12.3.2"
"markdown-it": "^12.3.2",
"markdown-it-footnote": "^3.0.3"
},
"devDependencies": {
"@11ty/eleventy": "^1.0.0",
@ -2628,6 +2629,11 @@
"markdown-it": "bin/markdown-it.js"
}
},
"node_modules/markdown-it-footnote": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/markdown-it-footnote/-/markdown-it-footnote-3.0.3.tgz",
"integrity": "sha512-YZMSuCGVZAjzKMn+xqIco9d1cLGxbELHZ9do/TSYVzraooV8ypsppKNmUJ0fVH5ljkCInQAtFpm8Rb3eXSrt5w=="
},
"node_modules/markdown-it/node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -6910,6 +6916,11 @@
}
}
},
"markdown-it-footnote": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/markdown-it-footnote/-/markdown-it-footnote-3.0.3.tgz",
"integrity": "sha512-YZMSuCGVZAjzKMn+xqIco9d1cLGxbELHZ9do/TSYVzraooV8ypsppKNmUJ0fVH5ljkCInQAtFpm8Rb3eXSrt5w=="
},
"maximatch": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/maximatch/-/maximatch-0.1.0.tgz",

View File

@ -26,6 +26,7 @@
"@sindresorhus/slugify": "^1.1.0",
"dotenv": "^10.0.0",
"gray-matter": "^4.0.3",
"markdown-it": "^12.3.2"
"markdown-it": "^12.3.2",
"markdown-it-footnote": "^3.0.3"
}
}

View File

@ -1,6 +1,9 @@
<script src="https://unpkg.com/mermaid/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({startOnLoad: true});
mermaid.initialize({
startOnLoad: true,
theme: "forest"
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js" integrity="sha512-hpZ5pDCF2bRCweL5WoA0/N1elet1KYL5mx3LP555Eg/0ZguaHawxNvEjF6O3rufAChs16HVNhEc6blF/rZoowQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-sv0slik/5O0JIPdLBCR2A3XDg/1U3WuDEheZfI/DI5n8Yqc3h5kjrnr46FGBNiUAJF7rE4LHKwQ/SoSLRKAxEA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>