Code blocks and snippets
DocStatic provides two ways to include code in your documentation. Both support syntax highlighting.
Code blocks
- Click the Code Block icon in the rich text editor.
- Click the language list and select or search for a language.
- Enter your code in the box.
Example:
This is some plain text.
Code snippets
- Select Code Snippet from the Embed list.
- Give it a Title.
- Select a Language.
- Choose a file from the list. The list is populated with all the files in the
reuse/code/folder every time you run the dev server or do a build.
Example:
Example Title
<div>
<p>Example</p>
</div>
The advantage of using code snippets is that there is a physical file that can be unit tested.
Related topics
- Snippets – Reusable topics.
- Admonitions – Handling admonitions/callouts in docStatic.
- Comments – Add invisible comments to Markdown files.
- Context-sensitive help – Using anchor tags to provide conditional sensitive help.
- Markdown links – Links to other pages in Markdown.
- Head metadata – Declaring page-specific head metadata through MDX.
- Conditional text – Filtering content with conditional text settings.