James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.57k stars 525 forks source link

[Feature Request] Sage syntax highlighting #1188

Closed tecosaur closed 5 years ago

tecosaur commented 5 years ago

For those who use sagetex, it would be quite nice if the various sage blocks could have python syntax highlighting applied, it may not be perfect but it's a lot nicer than nothing :grinning:

These are the various sage commands/environments:

Commands

Environments

NavyAdmiral commented 5 years ago

So happy to see a Sage user! Definitely a good feature request. I would love to add it, but I'm short on time for a bit.

jlelong commented 5 years ago

It is fairly easy to declare the sagexxx environments as Python codes and I will add this straightaway.

Unfortunately, it is far more difficult to achieve the same result with for inline code using \sage and \sagestr and moreover from the sagetex documentation it seems fairly common to have those functions inside maths environments.

The current syntax highlighting mechanism does not enable us to achieve such elaborate syntax matching inside maths blocks. Considering the syntax file is already several thousand lines long and very complex, I am reluctant to introduce so many changes for inline code. Sorry for this.

tecosaur commented 5 years ago

@jlelong That's fantastic to hear with the sage environments!

The sage inline commands would have been nice but are far, far less important in my opinion; as I can't imagine having much more than a single expression in them. Whereas the environments are prone to have quite a few lines in them.

Thanks again!

tecosaur commented 5 years ago

@NavyAdmiral A fellow sage user I assume?

Off Topic

Considering the PR you made in vsc-prettify-symbols-mode a while ago I have a feeling that you may be interested in my latest endeavour, giving up on that laggy, buggy non-maintained extension and adding symbol replacement via ligatures.

I've just started looking into this (see https://github.com/ToxicFrog/Ligaturizer/issues/60) and if you'd be interested in doing this colaboratively I'd appriciate the help.

If you'd like to discuss this more I could either fork the Ligaturizer repo or we could exchange email addresses.