Replace Math Blocks using Regex

Hi, I was using the partial from this blog post. It basically replaces html chars with […], then I realised it doesn’t handle math blocks. I thought I can extend the regex part to cover $…$ and $$…$$ blocks.

Yet I couldn’t handle it.

I have some regex candidates, don’t know if they work.


Second question is, I think I can’t use dollar sign, curly braces and quotation marks in the <regex_here> part below. Probably, because they are already used by Hugo. I tried to use backticks but it didn’t help.

{{ $.Scratch.Set "summary" ((... (findRE "<regex_here>" .Content ...)}}

Edit: I feel like I’m about to solve this and backticks are working. lol. I’ll update here, sorry for the mess.
Edit 2: I’m not going to delete the topic incase someone needs this.

This will do the job:

replaceRE `(\${1,2}(.|\n)*?\${1,2})` "[&hellip;] "

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.