Does anyone here know #pygments or #chroma lexer stuff well enough to tell me how (if at all?) one can mark up stuff in *multiple ways at once*?

For instance the following line:

# foo **bar**

The entire line should be a "Heading", the first two characters and the stars should be "Keyword"s, and the bar should be "GenericStrong".

I can't for the life of me figure out how that's possible to achieve.

CC @avghelper

The people who came up with "contact info in website footer" + "endless scrolling" must be the same people who came up with "terribly long documentation page" + "table of contents in sidebar only scrolls further down if you are near the end of the page".

https://pygments.org/docs/lexers/

#sphinx #pygments

Available lexers — Pygments

When in doubt of which type of code block alias to use in your RST file, pygments provides all available lexers 📜 for a neat documentation project
https://pygments.org/docs/lexers/
#pygments #RST #sphinx
Available lexers — Pygments

I'm wrapping up the last two pages of documentation for my thing and while documenting a handful of example commands in interactive mode, I thought

"Man wouldn't it be nice if this had syntax highlighting, at least for keywords and arguments? I wouldn't need to use 'console' for sphinx code blocks, and it would not be this drab gray..."

Fast forward 45 minutes later, I'm in the middle of a gnarly custom Pygments regex lexer and I think:

"Oh but what if I just read the commands module source tree and parsed the AST to extract command names from functions that have the typer decorator? I would never need to maintain that list again and they'd always be keywords!"

The real "What the fuck am I doing with my life?" moment was marginally offset by how it actually worked on first try, against all expectations.

Sphinx is insidious. Once you start extending it there's no end in sight.

#Python #Sphinx #Pygments #programming

Python-kodeblokk

Eksempel på kodeblokk med Python:

def main(): print("Hello, world!")Code language: Python (python)

Med Microformats-prefiks h-, p- o.l. så kunne kanskje formateringa vha. CSS-klasser ha sluppet gjennom.

… the #Pygments lexer for #CommonLisp treats ‘defun’ and ‘list*’ (among other symbols) as basically the same thing. They're both ‘builtins’.

As the kids say, my disappointment is immeasurable.

Ggghh, emacs --batch + font-lock-fontify-buffer + output the face changes maybe?

If you use the pygments syntax highlighter (for example in your documentation), and you have examples that produce output (for example from the shell or Python REPL), here is a tip that I just discovered: look for the "console session" version of your language on this page: https://pygments.org/languages/
It keeps the language's syntactic coloring while dealing correctly with the prompt and output. Also when you copy the code, it will avoid copying the prompt.

#Python #pygments #foss

Languages — Pygments

Service toot: Just in case you need a reason to update your #TeXLive:

#minted finally release the 3.0.0 which provides an own binary which makes the python/ #pygments setup obsolete. This also drops the requirement of shell-escape (or different hacks) to use the syntax highlighting.

Ensure to not only update the package itself, as you also need to update the settings which allow it to run in restricted mode.

#TeXLaTeX

#pygments 、Racket のコードもちゃんとシンタックスハイライティングしてくれるのかなり嬉しいな。
Racket に最初から入っている手続きに色が付いているので Racket の手続きやマクロのリストを持っているっぽい。
すばらしい。

Is Brent Roose on the Fediverse anywhere? I love this idea, and I’d love to help contribute.

I started down the path of trying to port #Pygments to #PHP a while back. I maintained a PHP wrapper for it (https://github.com/ramsey/pygments), and even set up a GitHub organization for “Phygments.” 😉 https://github.com/phygments

I want to help make this happen. Maybe I’ll have to email Brent if he’s not on the Fediverse.

@freekmurze @pronskiy Do either of you know if he’s here? https://mastodon.social/@php_discussions/112118298296419881

GitHub - ramsey/pygments: 💅 A PHP wrapper for Pygments, the Python syntax highlighter, forked from the Pygments.php project

💅 A PHP wrapper for Pygments, the Python syntax highlighter, forked from the Pygments.php project - ramsey/pygments

GitHub