Code
SevenMark uses CommonMark-style fenced code blocks. A code block starts at the beginning of a line with three or more backticks and ends with a line containing at least the same number of backticks.
Basic Code Block
```
function hello() {
console.log("Hello, World!");
}
```Parameters
Use SevenMark parameters after the opening fence. #lang is used by renderers for syntax highlighting, and common style parameters can customize the rendered block.
``` #lang="rust"
fn main() {
println!("Hello, world!");
}
```
``` #lang="python" #class="example-code"
def greet(name):
return f"Hello, {name}!"
```Parameters may also span multiple lines before the code body:
```
#lang="javascript"
#class="example-code"
console.log("Hello");
```Fence Length
If the code itself contains a triple-backtick fence, use a longer outer fence.
```` #lang="markdown"
```rust
fn main() {}
```
````Namumark Syntax Blocks
For migration compatibility, SevenMark also accepts Namumark #!syntax blocks and maps them to the same Code AST as fenced code blocks:
{{{#!syntax rust
fn main() {}
}}}The formatter normalizes this form back to SevenMark fenced code syntax.
Inline Code
Inline code uses matching backtick runs and does not cross line breaks:
Use `parse_document()` to parse source text.
Use ``one ` tick`` when the content contains a backtick.Notes
- The old
{{{#code ...}}}form is no longer code syntax. - Fenced code blocks are raw: markup inside the code body is not parsed.
- Opening and closing fences must start at column 0. Closing fences may use more backticks than the opener.