godot-docs
godot-docs copied to clipboard
Inline code hightlighting
while working on #11217 i was curious if it was possible to add inline code highlighting like we have it for the mod loader docs, and it turns out that it is possible by adding this to the files
.. role:: gd(code)
:language: gdscript
The following is the list of supported operators and their precedence. All binary operators are `left-associative <https://en.wikipedia.org/wiki/Operator_associativity>`_,
including the :gd:`**` operator. This means that :gd:`2 ** 2 ** 3` is equal to :gd:`(2 ** 2) ** 3`. Use parentheses to explicitly specify precedence you need, for
example :gd:`2 ** (2 ** 3)`. The ternary :gd:`if/else` operator is right-associative.
which does result in all the proper code highlights.
| Before | After |
|---|---|
note that :language: gd results in the old lexer being used, i think, so not everything is properly highlighted, but :language: gdscript works just fine.
now the question - do we want this? it's neat, but also quite some effort to pull through everywhere, especially when tables break. also new contributions should probably use this too, which adds a bit more contribution friction
regex replace with
``(.*?)``
:gd:`$1`
does work alright, but of course not everything is gdscript