I don’t see anything unusual. Looks like its passing the original string to me…
Here is the output I see (I’ve added a print at the top as well):
“text before any action:”
“this is a line
new line”
“Calling replaceText() normally:”
“this is a line new line”
“Calling replaceText() inside marked():”
“inside myRenderer.text - text before replaceText called”
“this is a line
new line”
“this is a line
new line”
“inside myRenderer.text - text after replaceText called”
Since you are passing the string “this is a line \r new line” to marked, I find it interesting that the console.log(text) string does not also show “this is a line \r new line”, but the marked function must do some pre-processing as it is passed into the function? I ask, because I have never used marked.js before and have not read about it at all. My observation may seem naive since, based on me not using marked.js before.
the console.log(text) string does not also show “this is a line \r new line”,
Yeah, the thing is using console.log() outside of marked results in the same output. I’m also not super familiar with Marked.js but as far as I can tell my renderer.link method should override the default completely. Here is the relevant docpage.
I went and looked at the marked.js source and it looks like it does in fact preprocess the strings it receives and replaces all \r's with \n's. Looks like I’ll have to deal with \r myself.