Code and math
Code and math extensions add code blocks, with or without syntax highlighting, and math formulas written in LaTeX.
Code block
Blocks of code on several lines.
Open source
Code block lowlight
Code blocks with syntax highlighting, using lowlight.
Open source
Mathematics
Write and render math formulas with LaTeX.
Open source
When you use them
- Code samples. Code block adds fenced code blocks, wrapped in
preandcodetags. - Highlighted code. Code block lowlight adds code blocks with syntax highlighting from the lowlight library.
- Formulas. Mathematics inserts LaTeX formulas, inline in a line of text or as a block, and renders them with KaTeX.
How they work
- They are nodes. Code blocks and math formulas are nodes in the document. Mathematics adds two of them, one for inline math and one for block math. Nodes and marks
- Code block comes with the StarterKit. Code block is part of the StarterKit; Code block lowlight and Mathematics you add yourself.
- Highlighting is separate. Code block has no styling and no syntax highlighting. Code block lowlight highlights code, and you pass it the
lowlightmodule with the languages you load. - Mathematics needs KaTeX. You install
katexwith the extension and import the KaTeX styles. - Markdown shortcuts. Typing three backticks and a space starts a code block. Add a language after the backticks, such as
css, to set it.
Related
- Text formatting includes the Code mark for a name or a command inside a sentence.
- Text blocks are the paragraphs and headings around your code.