Configure markdown-it-footnote

This commit is contained in:
Helen Chong 2024-05-17 22:44:02 +08:00
parent c8b7157a92
commit 886a4c49d5
1 changed files with 11 additions and 0 deletions

View File

@ -82,6 +82,17 @@ module.exports = function (eleventyConfig) {
'<ol class="footnotes-list">\n' '<ol class="footnotes-list">\n'
); );
const renderRules = {
footnote_caption: ['[', '[<span class="visually-hidden">Footnote </span>'],
footnote_anchor: ['<a', '<a aria-label="Back to content"'],
};
Object.keys(renderRules).map(rule => {
let defaultRender = markdownLibrary.renderer.rules[rule];
markdownLibrary.renderer.rules[rule] = (tokens, idx, options, env, self) => {
return defaultRender(tokens, idx, options, env, self).replace(...renderRules[rule]);
}
});
// Paired shortcode: custom container // Paired shortcode: custom container
eleventyConfig.addPairedShortcode('container', (children, el, className) => { eleventyConfig.addPairedShortcode('container', (children, el, className) => {
const classMarkup = className ? ` class="${className}"` : ""; const classMarkup = className ? ` class="${className}"` : "";