How to apply baseUrl with a custom renderer? #2398
-
Hello, I'm using marked with some custom rendering like so:
While the above works, I'd like to make use of the options to pass in a baseUrl to marked. The reason for this is I need it to apply to html that is parsed with marked, too. I've attempted to do something like:
It doesn't seem to have any effect, no matter if I put it before or after the Is this something that is possible, and if so how would I go about it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You can use |
Beta Was this translation helpful? Give feedback.
-
const renderer = {
link(href, title, text) {
return `<a href="${this.options.baseUrl}${href}">${text}</a>
}
} |
Beta Was this translation helpful? Give feedback.
-
There is no way to edit the href of links entered as HTML ( |
Beta Was this translation helpful? Give feedback.
There is no way to edit the href of links entered as HTML (
<a href=...
) inside marked. Marked doesn't parse html blocks (per the spec) it just passes them to the renderer. The only way to do that would be to create a new renderer or tokenizer the way you are.