Pygments plugin

Can you give me an idea on how to make the script output inline code (that can fit in a line with other text)?

It seems the output is wrapped with verbatim-code elements.

https://codeberg.org/woutersj/tm-pygments/src/branch/main/src/TeXmacsFormatter.py

You could try commenting out those lines.

While it does allow the code to be inline, as you as you start typing something else on the same line, it breaks and goes back to be on a separate line.

Is there a reason you used an external plugin? TeXmacs has syntax nightlight and it seems to me we should be able to program it via scheme. Have you given a look at this?

I am writing a presentation on verilog-a. Texmacs doesn’t have support for this. Even though pygments also doesn’t support this language, since I’m familiar with Python, it is was easier to write one. Also, pygments can be used within latex.

I was asking @jeroen. I understand, but I still think is a lot of complexity for a simple thing. I’ve looked at how parsers are implemented in pygments and this reminded me why I do not like python…

This is how parsers are implement in TeXmacs:

There is also an highlighter for a minimal language

I wonder if these code are used or if they are relics.

Can you give me an idea on how I can implement a syntax parser and get it detected inside texmacs. Maybe this would give me the opportunity to learn scheme.

I didn’t have a strong reason for using Pygments. Someone asked if it was possible to do and I saw it as an exercise to understand better the TeXmacs file format. Besides this it gives easy access to the many languages already in Pygments.

I believe the algorithms for code highlighting are in src/System/Language/prog_language.cpp and in plugins/code

1 Like

I understand, however I find that this is not optimal since it requires to run the plugin in order to get syntax highlighting. Unfortunately I still haven’t had the occasion to sit down and try to understand what Joris implemented and how to use it, or improve it, in order to have syntax highlighting and a nice way to extend it to multiple languages (and eventually to be able to export it to HTML and LaTeX).

Overall, I do not like much that we rely on python for many tasks (e.g. to implement plugins) this is going in the direction of “code bloating” and more seriously, prevents the contributors to TeXmacs to acquaint themselves with scheme scripting, thus realising a self-fulfilling prophecy, that we need to change scripting language. As I commented elsewhere Emacs does perfectly fine with scheme, so if we find a way to import or automatically translate Emacslisp syntax highlighting.

Btw, this does not mean that I do not appreciate your work on the plugins. :slight_smile: I hope to find some time to document the internal parser so we can try to evaluate if would make sense to use it instead.

I think we need to start the tutorials :slight_smile:

1 Like