Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell Haddock latex equation in comments

I'd like to use latex notation for equations in my source code. For example, I would write the following comment in some haskell source file Equations.hs:

-- | $v = \frac{dx}{dt}$

In the doc directory, this gets rendered by haddock in Equations.tex as:

{\char '44}v = frac{\char '173}dx{\char '175}{\char '173}dt{\char '175}{\char '44}

I found this function in the source for Haddock's latex backend that replaces many characters that are used in latex formatting:

latexMunge :: Char -> String -> String
...
latexMunge '$'  s = "{\\char '44}" ++ s

Is there any existing functionality that allows me to bypass this and insert latex equations in comments?

like image 668
Maarten Avatar asked Jun 15 '14 12:06

Maarten


1 Answers

No. The main reason why this (and similar features) don't exist is that it's unclear what to do with the markup in the other backends, be it HTML one, Hoogle one or whatever else someone might be using. This is fairly commonly requested but there is no common agreement and more importantly, no patches.

Technically we don't support the LaTeX backend, it's kept around compiling so that the Haskell Report can be produced. If you or someone else wants to give it some new life (and features) then we'll happily accept patches.

tl;dr: no can do. I know people simply pre-render LaTeX and insert the resulting images in with the image syntax.

like image 139
Mateusz Kowalczyk Avatar answered Nov 03 '22 07:11

Mateusz Kowalczyk