Wrap code in a fenced code block and mdbin highlights it automatically. Add a language after the opening fence to pick the grammar.
Writing a code block
Put three backticks, the language name, your code, then three backticks to close:
```js
export function greet(name) {
return `Hello, ${name}!`;
}
```
That renders as:
export function greet(name) {
return `Hello, ${name}!`;
}
The language is taken from the first word after the opening fence. If you leave it off — or use a name mdbin doesn't recognise — the block still renders, just without colouring:
no language here — plain, escaped text
Supported languages
Highlighting is powered by highlight.js (the common bundle), which covers the languages you'll reach for most often, including:
javascript, typescript, python, php, ruby, go, rust, java, c, cpp,
csharp, bash, shell, json, yaml, sql, css, html / xml, markdown, and more.
Use the language's common name as the fence info string (e.g. ```python).
Headings and anchors
Every heading gets a stable id and a hover anchor, so you can deep-link to any section. The id
is derived from the heading text (lowercased, h- prefixed), and duplicates are de-duplicated
within a document. Documents with several headings also get an automatic table of contents.
Links
Links are auto-detected and safe by default:
- Only
http,https,mailto, relative, and#links are allowed —javascript:and other unsafe protocols are rejected. - Every link opens in a new tab and carries
rel="nofollow noopener noreferrer".
What's sanitized
To keep shared documents safe to open:
- Raw HTML is disabled in Markdown — it's the primary defence against cross-site scripting.
- The rendered output is run through a sanitizer that strips dangerous tags and attributes
(e.g.
style,form,input, inline event handlers).
You never have to think about this — just write Markdown and it stays safe.