Table of Content
1. Full blocks of code 🔗
NML supports different kind of code blocks. The full block modes creates a (optionally titled), numbered code block. You can also specify the language of the block to get proper highlighting via the syntect crate.
Example:
The following...
```C, Factorial in C |
int factorial(int n) |
{ |
if (n <= 1) |
return 1; |
return n * factorial(n - 1); |
} |
``` |
...gives the following
Factorial in C
1 | int factorial(int n) |
2 | { |
3 | if (n <= 1) |
4 | return 1; |
5 | return n * factorial(n - 1); |
6 | } |
Properties 🔗
line_offset
: (number) The number of the first line (defaults: 0)
2. Mini blocks 🔗
Mini blocks are code blocks that can span on a single line (thus blending within a paragraph).
Example:
``Rust, str.chars().iter().fold(0, |acc, _| acc + 1)``
→str.chars().iter().fold(0, |acc, _| acc + 1)
``C++, auto car{ std::make_unique<Car>(...) };``
→auto car{ std::make_unique<Car>(...) };
Mini blocks can span multiple lines, in which case they become similar to full code blocks with the following differences:
- No title: Mini blocks cannot have a title at all
- No line numbers: Line numbers won't be shown
Example:
The following...
``Rust |
fn real_position( |
source: Rc<dyn Source>, |
position: usize |
) -> (Rc<dyn Source>, usize) |
{ |
if let Some(parent) = source.parent |
{ |
return real_position(parent.clone(), source.apply_offsets(position)); |
} |
return (source.clone(), source.apply_offsets(position)); |
} |
`` |
...gives the following
fn real_position( |
source: Rc<dyn Source>, |
position: usize |
) -> (Rc<dyn Source>, usize) |
{ |
if let Some(parent) = source.parent |
{ |
return real_position(parent.clone(), source.apply_offsets(position)); |
} |
return (source.clone(), source.apply_offsets(position)); |
} |
3. Code theme 🔗
Code theme can be controlled by the variable code.theme
. The default value is base16-ocean.dark
. According to syntect's documentation, the following themes are available: