Skip to content

Linking back to the source #3591

Answered by UziTech
PeterWone asked this question in Q&A
Jan 16, 2025 · 4 comments · 3 replies
Discussion options

You must be logged in to vote

token.text is the markdown text not the html text. To parse the tokens to html use this.parser.parseInline(tokens) for inline tokens or this.parser.parse(tokens) for block tokens

heading(token: Tokens.Heading) {
  return `<h${token.depth} data-raw="${token.raw}">${this.parser.parseInline(token.tokens)}</h${token.depth}>`;
},
blockquote(token: Tokens.Blockquote) {
  return `<blockquote data-raw="${token.raw}">${this.parser.parse(token.tokens)}</blockquote>`;
},

There are lots of edge cases the renderers have to deal with so instead of writing your own I would suggest copying marked renderers and changing the output or just adding to the marked renderer output.

import { marked, Parser, Rend…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@UziTech
Comment options

Answer selected by PeterWone
@PeterWone
Comment options

@PeterWone
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants