I have a setup where I use Doxygen to import the contents of a README.md file into my package documentation. I have Github-friendly mathjax in README.md, delimited by $` and `$, which I need to change to Doxygen-friendly \f$ in before importing. In my Makefile, I have the following recipe:
docs: FORCE
@sed -e 's|`$$|\\f$$|g' -e 's|$$`|\\f$$|g' README.md > _README.md
@doxygen
sed captures the $` expression and swaps it with \f$, the leading mathjax delimiter in Doxygen — for example, $` \mathbb Z gets changed to \f$ \mathbb Z, as it should be. However, it doesn't capture `$ (leaving it unchanged) and turns all triple-backticks ``` to ``\f$ . How can I get sed/some other text replacement program to replace these characters properly?