Disable underscore for italic text

Hello,

I use a lof of LaTeX (via MathJax) for my blog posts, and the underscore character has caused quite a lot of issues (sometimes it works, sometimes I had to put a backlash for the math be displayed).

I would like to know if there is a way to completely disable the use of underscore for italicizing.

Thank you in advance for your help!

1 Like

The star (*) character should be also disabled. It would be very much appreciated if somebody could tell me how to replace _ and * with a different delimiters. For example:

  • Using two consecutive :, such as ::italic text::.
  • Using two consecutive ^^, such as ^^italic text^^.

You’re basically talking about changing the defined syntax of Markdown, so the parser Hugo uses would have to be changed.

The solution is probably to create your own shortcode, so anything inside isn’t processed by the Markdown parser. Simple enough.

made my shortcode tex.html for this last week

${{safeHTML .Inner}}$

in the content

Ampère's Law {{<tex>}}{\vec {\nabla }}\times {\vec {B}}=\mu _{0}{\vec {j}}+\mu _{0}\varepsilon _{0}{\frac {\partial {\vec {E}}}{\partial t}}{{</tex>}}

Works for me very well

@angus @ju52 Thanks for your replies!

The solution is probably to create your own shortcode, so anything inside isn’t processed by the Markdown parser. Simple enough.

In some blog posts I have thousands of formulas, with a large part copied directly from my papers written in LaTeX, so adding a pair of delimiters to each formula is not practical at all (not to mention also that it would be much more laborious than simply adding \ to the underscores that fail Edited: I forgot that one can choose to use the shortcode only for formulas that fail). If there’s no simple solution then I think I can live with that.

If you’re using a text editor with any kind of regex, search/replase, or text snippets, would be easy to either batch fix or use the shortcode going forward to prevent errors in the future.