I’m using commonmark.js to render markdown on my site. I’d like to change the way a couple tags are generated:
- anchor tags (
<a/>): I’d like to add
target="_blank"based on the href’s value.
- headings (
h2, etc): I’d like to set the heading’s
idattribute based on a convention.
What’s the best way to accomplish this? Is there a way to plugin this logic to commonmark.js or should I directly manipulate the rendered output using jquery/etc?
I’ve seen the documentation here on walking the AST but it doesn’t look like this will allow me to do anything that would have the effect of adding attributes to the rendered HTML.