Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerzl committed Sep 18, 2023
1 parent b16fb46 commit 7d47b4c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/node/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ export const createMarkdownRenderer = async (
}
}

// custom rules
const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};

md.renderer.rules.heading_open = function (tokens, idx, options, env, self) { //
let token = tokens[idx];

if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(token.tag)) {
token.attrPush(['aria-label', tokens[idx+1].content])
}

return defaultRender(tokens, idx, options, env, self);
};

// apply user config
if (options.config) {
options.config(md)
Expand Down

0 comments on commit 7d47b4c

Please sign in to comment.