godotengine / godotengine/godot-docs

Inline code hightlighting

Open
#11,248 6 comments 5 reactions 0 assignees View on GitHub
content:website enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

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

```rst
.. role:: gd(code)
:language: gdscript

The following is the list of supported operators and their precedence. All binary operators are `left-associative `_,
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 |
|---|---|
|Image|Image|

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
```regex
``(.*?)``
:gd:`$1`
```
does work alright, but of course not everything is gdscript

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.