Code and Syntax Highlighting
Explain a command, document an API, or review a source file with syntax highlighting. Add a language tag to a fenced block, or open a supported source file directly in your vault. MDash uses Shiki to highlight code while preserving the original text for copying and export.
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. For example, put this TypeScript function in a project brief:
```ts
function taskLabel(completed: boolean): string {
return completed ? 'Complete' : 'To do';
}
```
The language tag selects the grammar. A fence without a language tag remains a plain monospace block. An unknown tag also falls back to plain code so the document remains readable.
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, or press Ctrl/⌘ + Alt + C while the editor is focused, 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.
In workspace Preview, shared documents, and public guides, hover over a code block or press Tab until Copy Code receives focus. On a touch screen, tap the visible Copy button. If clipboard access fails, MDash selects the code so you can copy it manually.
Open Settings → View → Code in Preview to wrap long lines, show line numbers, or set the tab width. Leave wrapping off if you prefer to scroll horizontally. Copying code leaves out line numbers. Recognized code files use the same highlighting and Preview preferences as fenced code blocks. The status bar shows the detected language.
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. MDash accepts recognized tags case-insensitively, so TypeScript and typescript use the same grammar. Lowercase tags are easier to scan and are the convention used in these examples. Rendering does not rewrite the tag in your stored source.
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
Use a short example that helps readers complete a task. Include the inputs, the relevant code, and the expected result in nearby prose. A complete source file can live beside the Markdown explanation; the next section shows that workflow.
TypeScript
This function trims a note's title and supplies a readable fallback for an empty title. The sample calls show both results.
interface Note {
id: string;
title: string;
}
function displayTitle(note: Note): string {
return note.title.trim() || 'Untitled';
}
displayTitle({ id: 'n1', title: ' Draft notes ' }); // 'Draft notes'
displayTitle({ id: 'n2', title: ' ' }); // 'Untitled'
Python
For a simple space-separated text sample, this returns a count of five words. It is a small Python example rather than MDash's own multilingual word counter:
def word_count(text: str) -> int:
return len(text.split())
print(word_count("Write clearly and edit carefully."))
Shell
These commands install a project's locked dependencies, check its TypeScript types, and produce a build. Use a project with an npm lockfile and typecheck and build scripts.
npm ci
npm run typecheck
npm run build
JSON
This fictional configuration shows strings, a Boolean, and an array.
{
"name": "example-project",
"private": true,
"features": ["math", "diagrams", "wiki-links"]
}
TSX
This React component displays Saved when saved is true and Saving… when it is false.
export function SaveStatus({ saved }: { saved: boolean }) {
return <span>{saved ? 'Saved' : 'Saving…'}</span>;
}
SQL
This query shows the most recently updated active notes first. For example, if both Draft and Review are active and Review was updated later, it appears first. An archived note is excluded regardless of its date.
SELECT title, updated_at
FROM notes
WHERE archived = FALSE
ORDER BY updated_at DESC;
YAML
This example highlights a YAML block list. MDash's own frontmatter uses inline arrays for tags, such as tags: ["planning", "markdown"].
title: Project Notes
tags:
- planning
- markdown
Work with Code Files
Keep Markdown explanations and source files together in a project folder:
Project/
README.md
docs/
Brief.md
src/
index.html
styles.css
app.js
Use this tree as an example when importing an existing project folder. Open Project/src/app.js in MDash to edit it as JavaScript and inspect its highlighted source in Preview. Add [JavaScript source](src/app.js) to Project/README.md to link to it. The file extension selects the language for a code file, while a fenced block uses its language tag.
HTML, CSS, and JavaScript files are displayed as source. MDash does not run them as a website. Use your normal development tools to execute the project. Import, Export, and Backup explains how to import a project folder and export its text files.
Theme and Layout
Highlighted colors follow the application theme. With wrapping off, long lines scroll horizontally inside the code block. Enable Wrap Code Lines in Settings > View when wrapping is easier to read. Presentation slides also 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.
Change the Code Font
JetBrains Mono is the default. To change it, open Settings → Fonts → Code Font. The bundled fonts include Fira Code, Iosevka Charon Mono, and the Monaspace families.
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:
-> => != !== == === <= >= :: ...
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, it displays plain code. Use
textexplicitly for neutral output or choose a compatible grammar such asshelloryaml.
Related Guides
Annex: Complete Language Reference
Use a primary tag or one of its aliases after the opening fence.
Show All Bundled Languages and Aliases
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 |