Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing to pass options to url resp. pygments #1

Open
Aschroet opened this issue Oct 22, 2020 · 1 comment
Open

Allowing to pass options to url resp. pygments #1

Aschroet opened this issue Oct 22, 2020 · 1 comment

Comments

@Aschroet
Copy link

A long time we were searching for a solution to solve the performance problems with the Mediawiki SyntaxHightlight extension which calls python for each code block separately. Before we got completely frustrated we came across this project which solved our issue. Thank you very much for it.
To let the pymets-server run together with SyntaxHighlight we modified the main.py a bit because we needed to pass certain options (e. g. cssclass) to the pygments formatter.

To avoid such hacks which could also occur in other use cases, we suggest to add an "options" url parameter (maybe "style" should be removed then) to the pygmentize server method which then passes them into the function call of _get_formatter_by_name(alias, **options). When calling pygmetize with Python such option are passed like -O cssclass=mw-highlight,encoding=utf-8. Maybe the url could then be like this: http://server:port?lang=sql&options=cssclass%3Dmw-highlight%2Cencoding%3Dutf-8. Of course, another flexible format is also possible. Finally, the options parameter is then taken, decoded and decomposed before it is passed to the method get_formatter_by_name.

We would be very grateful if somebody comments or even works on this feature.

@lucaswerkmeister
Copy link

I didn’t see this issue until just now, but I also ran into issues using pygments-server with MediaWiki’s SyntaxHighlight, and eventually decided to implement my own version that wraps pygments.cmdline rather than pygments.highlight, so that it supports all pygmentize flags and options. You can find it at lucaswerkmeister/pygments-server; maybe others find it useful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants