opendocs uses the rehype-pretty-code library
to handle the codes in MDX files. This allows you to greatly customize the way codes are displayed!
For more information, see the official documentation and examples!
Titles
Example:
Code:
Code highlighting
Example:
Code:
Inline code highlighting
Example:
The result of [1, 2, 3].join('-') is '1-2-3'.
Code:
Context-aware inline code highlighting
For example, if you had the following block of code:
When we refer to getStringLength as a function,
we can color it as such. Same with function, or
str vs. str, etc. This allows
semantically link inline code to the nearest block of code it refers to.
Code:
Word highlighting
Example:
Code:
Line highlighting
Example:
Code:
Line numbering
Example:
Code:
Diff
Example:
Code:
ANSI Highlight
Example:
Inline ANSI: > Local: http://localhost:3000/
Code:
Word group highlighting by id
Put an id after # after the words.
This allows you to color characters differently based on the given id.