Symbolic-math-HaTeX icon indicating copy to clipboard operation
Symbolic-math-HaTeX copied to clipboard

`equations` silently changes labels – better: type-checked labels

Open jorsn opened this issue 4 years ago • 2 comments

The function equations creates labels using

asSafeLabel = LaTeX.label . fromString . filter isAlpha

defined at https:../blob/dbfff7d6ab0f184892e62d3c9829495fa46a170f/Math/LaTeX/Internal/Display.hs#L114.

filter isAlpha silently changes labels named e.g. like eq:…, hence breaks common practices of LaTeX label naming.

Since this filtering is not necessarily expected or desired by a user (like me), I'd suggest to make it optional (e.g. provide a version of equations with an argument filterLabel :: String -> String).

Really nice would be compile-time checking of labels and failure if it didn't fit the specification. I have implemented something as proof of concept: https://gist.github.com/jorsn/b86dd25b73b6b3bd6685a5a403bc481f

Should this better go into HaTeX directly? It can probably also be modified to sanitize general HaTeX labels.

jorsn avatar Jun 11 '20 20:06 jorsn