Prettier, which I’m using when working with Markdown turns dollar signs into escaped versions thereof (i.e. $ turns into \$). Hugo’s parser renders this to include the backslash in the HTML, which is pretty annoying in my use case. What’s the reasoning behind this? Is this something that can be changed in the settings? Is escaping the dollar sign in Markdown unusual? What am I not seeing here?
It would be awesome if someone could shed some light on this for me.
This would be a viable solution and in fact what I’d do if this were a one off. However, the text (prose) I’m formatting contains a bunch of dollar signs. So it I did it in the way you suggested, things would get rather cluttered and cumbersome.
Hugo uses Blackfriday for markdown processing. I am not familiar with what characters are commonly escaped by markdown processors, but if you think that Blackfriday should handle this differently, create an issue there.
The dollar sign has no special meaning in Markdown, and Markdown does not recognize the escaping of it.
Bottom line: this isn’t a Hugo problem. Hugo is accurately rendering what you’re sending it.
Indeed. I found that thread as well before posting here. It appears that MultiMarkdown supports LaTeX style dollar sign delimiters for mathematical expressions (https://fletcher.github.io/MultiMarkdown-5/math.html) , which - I’m guessing - is why Prettier escapes them. So I’m thinking that’s where the core of the issue is to be located.
The reason why I posted here was to see whether anyone had similar experiences and maybe found a solution that didn’t include outright disabling Prettier for Markdown files in Hugo projects :).
I can’t for the life of me find a work-around for this other than telling my code editor I’m not working with Markdown when I have a $ in my prose, which leads to a whole host of other issues. This is directly tied to Prettier, not Hugo or Black Friday.
Maybe I’m wrong. I just went to comment on an issue on Prettier’s GitHub. GitHub Markdown seems to ignore a leading backslash… when it encounters \$ it renders $.
For now I guess I’ll disable prettier for Markdown files
Markdown has never really had a full-blown spec, so I’m not surprised when different renderers do different things. However, I did see that the CommonMark spec (assumed to be eventual successor of Markdown) does define a dollar sign as a valid escape sequence.
So, I expect this will eventually be supported in Hugo. I haven’t verified this, but I believe Blackfriday v2 is aiming at CommonMark compliance. Hugo uses Blackfriday v1. See our discussion on moving to BFv2 for more about this topic.