-
I am working on writing some extensions so I can take a markdown file and render it in a way that works with tufte-css. The problem I'm facing is that I'd like to process child tokens of my const regex = /^(@footer ?(paragraph|[^\n]*)(?:\n|$))+/
const extension = {
name: 'footer',
level: 'block',
start(src) {
return src.match(/@footer/)?.index;
},
tokenizer(src, _tokens) {
const cap = regex.exec(src);
if (cap) {
const text = cap[0].replace(/^@footer[ \t]?/gm, '');
const tokens = this.lexer.blockTokens(text);
return {
type: 'footer',
raw: cap[0],
tokens,
text
};
}
},
renderer(token) {
return `<footer>${this.parser.parse(token.tokens)}</footer>`
}
}
export default extension It takes this: @footer <cite>[Le Bourgeois gentilhomme](https://www.gutenberg.org/files/2992/2992-h/2992-h.htm)</cite> And renders this: <footer>
<p>
<cite><a href="https://www.gutenberg.org/files/2992/2992-h/2992-h.htm">Le Bourgeois gentilhomme</a></cite>
</p>
</footer> However, I want it to render as:
Is there a way to omit the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If there will only be inline tokens you can do |
Beta Was this translation helpful? Give feedback.
If there will only be inline tokens you can do
this.parser.parseInline(token.tokens)
in the renderer.