Code and Syntax Highlighting
MDash uses Shiki and bundled language grammars to highlight fenced code blocks. Add a language tag to select the syntax rules and colors for a block. For the surrounding document syntax, see the Markdown Guide.
Table of Contents
Inline Code
Wrap a short snippet in backticks:
Run `npm install` before the first build.
Inline code works well for commands, variable names, and paths.
If the snippet itself contains a backtick, wrap it in two backticks:
``Use `code` inside the snippet.``
Fenced Code Blocks
Use three backticks and add a language tag:
```ts
const greeting: string = 'Hello';
```
The language tag selects the grammar. A fence without a language tag remains a plain monospace block.
A fenced code block is recognized only after a matching closing fence exists. Until then, MDash keeps the opening marker literal and continues rendering the following Markdown normally.
Choose Insert Code Block in the toolbar to search every bundled language, enter a custom supported tag, and write or paste code beside a live highlighted preview. Place the cursor inside an existing fenced block to edit its language and source through the same modal. If the code contains triple backticks, MDash automatically uses a longer outer fence.
Hover over a rendered code block to reveal Copy Code. If clipboard access fails, MDash selects the source so you can copy it manually.
Open Settings, choose View, and use Code in Preview to wrap long lines, show line numbers, or select a tab size. The options are independent: leave wrapping off for horizontal scrolling, enable line numbers for review, or use a narrower tab width in compact Preview panes. Line numbers are visual and are never included when you copy code. Recognized code files use the same highlighting and Preview preferences as fenced code blocks, and their detected language appears in the footer.
Common Language Tags
MDash supports Shiki's bundled language set. Common tags include:
| Language | Tag |
|---|---|
| TypeScript | ts or typescript |
| JavaScript | js or javascript |
| React | tsx or jsx |
| Python | python |
| Rust | rust |
| Go | go |
| Java | java |
| C | c |
| C++ | cpp |
| C# | csharp |
| HTML | html |
| CSS | css |
| JSON | json |
| YAML | yaml |
| SQL | sql |
| Shell | bash or shell |
| PowerShell | powershell |
| Markdown | md or markdown |
| nginx | nginx |
| Dockerfile | docker or dockerfile |
Use the primary language name or a supported alias. Tags are case-insensitive, but lowercase tags are easier to scan and copy.
For every recognized primary tag and alias, see the complete language reference at the end of this guide.
Choose a Specific Tag or Plain Text
Choose the most specific tag when readers benefit from syntax colors, such as tsx, json, or sql. Use text when the content is console output, pseudocode, or a format without a suitable grammar. Leave the tag empty only when you deliberately want a plain monospace block.
If a specialized tag is unavailable, choose a broader compatible grammar. For example, shell is a practical fallback for an uncommon command-line language, while yaml can be useful for a configuration format with similar structure.
Examples
TypeScript
interface Note {
id: string;
title: string;
}
function displayTitle(note: Note): string {
return note.title.trim() || 'Untitled';
}
Python
def word_count(text: str) -> int:
return len(text.split())
print(word_count("Write clearly and edit carefully."))
Shell
npm ci
npm run typecheck
npm run build
JSON
{
"name": "mdash",
"private": true,
"features": ["math", "diagrams", "wiki-links"]
}
TSX
export function SaveStatus({ saved }: { saved: boolean }) {
return <span>{saved ? 'Saved' : 'Saving'}</span>;
}
SQL
SELECT title, updated_at
FROM notes
WHERE archived = FALSE
ORDER BY updated_at DESC;
YAML
title: Project Notes
tags:
- planning
- markdown
Theme and Layout
Highlighted colors follow the application theme. Long lines stay inside the code block with horizontal scrolling, and presentation slides allow long blocks to scroll.
Inline code is sized to sit naturally within prose. Fenced code, the editor, and code-file Preview follow the configured Text Size.
Coding Ligatures
Coding ligatures combine familiar operator sequences into clearer visual symbols without changing the source text, cursor positions, copying, searching, or exported Markdown. Open Settings, choose Fonts, and use Coding Ligatures to enable or disable them independently of the selected code font.
MDash bundles its code fonts locally. The included Monaspace families, JetBrains Mono, Fira Code, and Iosevka Charon Mono support common sequences such as:
-> => != !== == === <= >= :: ...
The exact drawing differs by family. Monaspace Neon is the default balanced design; Argon is more humanist, Krypton is more mechanical, Radon is more expressive, and Xenon is more slab-like. Choose the family for its overall readability rather than the number of ligatures it provides.
Turn ligatures off when you want every source character to remain visually separate, especially while teaching syntax or reviewing punctuation-heavy code.
Tips
- Add a language tag whenever you want highlighting.
- Keep presentation examples focused so the audience can read them.
- Copying returns the original source, not the highlighted HTML.
- Use
textfor output or examples that should remain visually neutral.
Troubleshooting
- If a fence stays plain, check the language tag spelling and remove punctuation after it.
- If MDash does not recognize a language, use a broader tag such as
text,shell, oryaml. - Very long lines scroll horizontally. Enable Wrap Code Lines in Settings > View when you want lines to wrap without changing the source.
Related Guides
Annex: Complete Language Reference
Use a primary tag or one of its aliases after the opening fence.
This annex reflects Shiki 1.29.2 and includes all 218 bundled grammars.
| Language | Primary Tag | Aliases |
|---|---|---|
| 1C (Enterprise) | bsl | 1c |
| 1C (Query) | sdbl | 1c-query |
| ABAP | abap | None |
| ActionScript | actionscript-3 | None |
| Ada | ada | None |
| Angular HTML | angular-html | None |
| Angular TypeScript | angular-ts | None |
| Apache Conf | apache | None |
| Apex | apex | None |
| APL | apl | None |
| AppleScript | applescript | None |
| Ara | ara | None |
| AsciiDoc | asciidoc | adoc |
| ASP.NET Razor | razor | None |
| Assembly | asm | None |
| Astro | astro | None |
| AWK | awk | None |
| Ballerina | ballerina | None |
| Batch File | bat | batch |
| Beancount | beancount | None |
| Berry | berry | be |
| BibTeX | bibtex | None |
| Bicep | bicep | None |
| Blade | blade | None |
| C | c | None |
| C# | csharp | c#, cs |
| C++ | cpp | c++ |
| Cadence | cadence | cdc |
| Cairo | cairo | None |
| Clarity | clarity | None |
| Clojure | clojure | clj |
| Closure Templates | soy | closure-templates |
| CMake | cmake | None |
| COBOL | cobol | None |
| CODEOWNERS | codeowners | None |
| CodeQL | codeql | ql |
| CoffeeScript | coffee | coffeescript |
| Common Lisp | common-lisp | lisp |
| Coq | coq | None |
| Crystal | crystal | None |
| CSS | css | None |
| CSV | csv | None |
| CUE | cue | None |
| Cypher | cypher | cql |
| D | d | None |
| Dart | dart | None |
| DAX | dax | None |
| Desktop | desktop | None |
| Diff | diff | None |
| Dockerfile | docker | dockerfile |
| dotEnv | dotenv | None |
| Dream Maker | dream-maker | None |
| Edge | edge | None |
| Elixir | elixir | None |
| Elm | elm | None |
| Emacs Lisp | emacs-lisp | elisp |
| ERB | erb | None |
| Erlang | erlang | erl |
| F# | fsharp | f#, fs |
| Fennel | fennel | None |
| Fish | fish | None |
| Fluent | fluent | ftl |
| Fortran (Fixed Form) | fortran-fixed-form | f, f77, for |
| Fortran (Free Form) | fortran-free-form | f03, f08, f18, f90, f95 |
| GDResource | gdresource | None |
| GDScript | gdscript | None |
| GDShader | gdshader | None |
| Genie | genie | None |
| Gettext PO | po | pot, potx |
| Gherkin | gherkin | None |
| Git Commit Message | git-commit | None |
| Git Rebase Message | git-rebase | None |
| Gleam | gleam | None |
| Glimmer JS | glimmer-js | gjs |
| Glimmer TS | glimmer-ts | gts |
| GLSL | glsl | None |
| Gnuplot | gnuplot | None |
| Go | go | None |
| GraphQL | graphql | gql |
| Groovy | groovy | None |
| Hack | hack | None |
| Handlebars | handlebars | hbs |
| HashiCorp HCL | hcl | None |
| Haskell | haskell | hs |
| Haxe | haxe | None |
| Hjson | hjson | None |
| HLSL | hlsl | None |
| HTML | html | None |
| HTML (Derivative) | html-derivative | None |
| HTTP | http | None |
| HXML | hxml | None |
| Hy | hy | None |
| Imba | imba | None |
| INI | ini | properties |
| Java | java | None |
| JavaScript | javascript | js |
| Jinja | jinja | None |
| Jison | jison | None |
| JSON | json | None |
| JSON Lines | jsonl | None |
| JSON with Comments | jsonc | None |
| JSON5 | json5 | None |
| Jsonnet | jsonnet | None |
| JSSM | jssm | fsl |
| JSX | jsx | None |
| Julia | julia | jl |
| Kotlin | kotlin | kt, kts |
| Kusto | kusto | kql |
| LaTeX | latex | None |
| Lean 4 | lean | lean4 |
| Less | less | None |
| Liquid | liquid | None |
| Log file | log | None |
| Logo | logo | None |
| Lua | lua | None |
| Luau | luau | None |
| Makefile | make | makefile |
| Markdown | markdown | md |
| Marko | marko | None |
| MATLAB | matlab | None |
| MDC | mdc | None |
| MDX | mdx | None |
| Mermaid | mermaid | mmd |
| MIPS Assembly | mipsasm | mips |
| Mojo | mojo | None |
| Move | move | None |
| Narrat Language | narrat | nar |
| Nextflow | nextflow | nf |
| Nginx | nginx | None |
| Nim | nim | None |
| Nix | nix | None |
| nushell | nushell | nu |
| Objective-C | objective-c | objc |
| Objective-C++ | objective-cpp | None |
| OCaml | ocaml | None |
| Pascal | pascal | None |
| Perl | perl | None |
| PHP | php | None |
| PL/SQL | plsql | None |
| Polar | polar | None |
| PostCSS | postcss | None |
| PowerQuery | powerquery | None |
| PowerShell | powershell | ps, ps1 |
| Prisma | prisma | None |
| Prolog | prolog | None |
| Protocol Buffer 3 | proto | protobuf |
| Pug | pug | jade |
| Puppet | puppet | None |
| PureScript | purescript | None |
| Python | python | py |
| QML | qml | None |
| QML Directory | qmldir | None |
| Qt Style Sheets | qss | None |
| R | r | None |
| Racket | racket | None |
| Raku | raku | perl6 |
| RegExp | regexp | regex |
| Rel | rel | None |
| reStructuredText | rst | None |
| RISC-V | riscv | None |
| Ruby | ruby | rb |
| Ruby Haml | haml | None |
| Rust | rust | rs |
| SAS | sas | None |
| Sass | sass | None |
| Scala | scala | None |
| Scheme | scheme | None |
| SCSS | scss | None |
| ShaderLab | shaderlab | shader |
| Shell | shellscript | bash, sh, shell, zsh |
| Shell Session | shellsession | console |
| Smalltalk | smalltalk | None |
| Solidity | solidity | None |
| SPARQL | sparql | None |
| Splunk Query Language | splunk | spl |
| SQL | sql | None |
| SSH Config | ssh-config | None |
| Stata | stata | None |
| Stylus | stylus | styl |
| Svelte | svelte | None |
| Swift | swift | None |
| Systemd Units | systemd | None |
| SystemVerilog | system-verilog | None |
| TalonScript | talonscript | talon |
| Tasl | tasl | None |
| Tcl | tcl | None |
| Templ | templ | None |
| Terraform | terraform | tf, tfvars |
| TeX | tex | None |
| TOML | toml | None |
| TSV | tsv | None |
| TSX | tsx | None |
| Turtle | turtle | None |
| Twig | twig | None |
| TypeScript | typescript | ts |
| TypeScript with Tags | ts-tags | lit |
| TypeSpec | typespec | tsp |
| Typst | typst | typ |
| V | v | None |
| Vala | vala | None |
| Verilog | verilog | None |
| VHDL | vhdl | None |
| Vim Script | viml | vim, vimscript |
| Visual Basic | vb | cmd |
| Vue | vue | None |
| Vue HTML | vue-html | None |
| Vyper | vyper | vy |
| WebAssembly | wasm | None |
| Wenyan | wenyan | 文言 |
| WGSL | wgsl | None |
| Wikitext | wikitext | mediawiki, wiki |
| Windows Registry Script | reg | None |
| Wolfram | wolfram | wl |
| XML | xml | None |
| XSL | xsl | None |
| YAML | yaml | yml |
| ZenScript | zenscript | None |
| Zig | zig | None |