src/sage/misc/sagedoc.py: Add latex to unicode mappings#35493
src/sage/misc/sagedoc.py: Add latex to unicode mappings#35493mkoeppe wants to merge 1 commit intosagemath:developfrom
Conversation
|
I agree with this, but I forget what our policy is on assuming that users have a terminal that supports unicode. Also, what about the other (more common) Greek letters? It would look quite weird to only have some of them changed to unicode. |
|
At JabRef we have made good experiences with the small latex2unicode library. It's written in Scala, so not reusable here but the encoding map is rather complete: https://github.com/tomtung/latex2unicode/blob/master/src/main/scala/com/github/tomtung/latex2unicode/helper/Escape.scala |
I don't think we have a policy for this formulated anywhere. The I wouldn't be concerned about terminal capabilities. I'd think the most plausible compatibility issue would be (1) workflows in which users copy-paste terminal output into a LaTeX document, without loading the necessary packages for input and font configuration; or (2) programs that run Sage as a subprocess. |
Thanks for the pointer! Looking great. I think somewhere in IPython/Jupyter there also must be a package that contains such mappings already, for offering tab-completion with the latex names. |
Yes, it's not complete, of course; this is just a mockup that makes Also, because the substitutions are regex-based, there is a potential for breakage from unintended matches. For example, so far I have shied away from handling the |
|
And finally, it seems to me that this is something that should be taken care of in a more reusable way, perhaps a Sphinx extension. Mildly related: |
The unfortunate side-effect is that it makes any doc that only does part of it look very broken. This is a good proof-of-concept right now, but I think it would be hard to convince people that our doc formatter is not horribly broken without doing certain subsets (e.g., all Greek letters).
Indeed, that might be a hard one to deal with. I think we would be better of replacing our docstrings with something like |
I found these but haven't looked at them in any detail:
|
|
Documentation preview for this PR (built with commit e17b688; changes) is ready! 🎉 |
📚 Description
Docstrings formatted for the terminal, in uses like
CliffordAlgebra?, are difficult to read when heavy LaTeX markup is used.We add some mappings that replace LaTeX commands by Unicode characters.
Resolves #35491
📝 Checklist
⌛ Dependencies