I’ve already setup Katex parser in layouts JS header. LaTex math expression in inline mode ($
) and display mode ($$
) both work great until I type percentage sign (%
).
In LaTeX, the %
sign starts a comment, so it needs to be escaped with a backslash to display the symbol literally. Like this
$10\% = 0.1$
However, Goldmark and Github flavoured markdown renderer also use backslash to escape punctuation characters like !
, %
, &
, etc. Thus, it needs double backslash in markdown to pass one \
to LaTex renderer Katex to display %
. Like this,
$10\\% = 0.1$
Double backslash doesn’t work in LaTex system, neither many other markdown renderer, like pandoc
.
If I change defaultMarkdownHandler
of hugo configuration to pandoc
, it does parse the raw LaTex snippet well and fix my problem. But pandoc
leads to another problem, the code block syntax highlighting doesn’t work in Hugo.
My questions:
- Is there anyway to configure Goldmark to disable escaping? From my perspective, markdown is a plain text document, I never need to escape characters in a plain text file. And I don’t want to maintain two versions of code and document.
- If I have to switch to
pandoc
as markdown renderer, how to enable code block synatx highlighting in Hugo?
Thanks in advance.