Syntax Highlighting
Beautiful code blocks for 190+ programming languages
AnySlate automatically highlights code in your documents, making it easy to read and understand. With support for over 190 programming languages, automatic language detection, and features like line numbers and copy-to-clipboard, your code blocks will look professional and be easy to work with.
Overview
190+ Languages
Support for virtually every programming language and format.
Line Numbers
Optional line numbers for easier code reference.
Copy Button
One-click copy to clipboard for any code block.
Auto Detection
Automatic language detection when not specified.
Code Block Syntax
Creating Code Blocks
Use triple backticks followed by the language identifier to create a syntax-highlighted code block. The language identifier is optional but recommended for accurate highlighting.
Basic syntax:
```javascript const greeting = "Hello, World!"; console.log(greeting); ```
Without language (auto-detection):
```
function example() {
return true;
}
```Language Detection
Automatic Detection
When you don't specify a language, AnySlate attempts to automatically detect the language based on the code content. For best results, always specify the language explicitly.
Recommended
```pythonExplicit language = accurate highlighting
Works but less reliable
```Auto-detection may not always be accurate
Line Numbers
Enable Line Numbers
Line numbers help readers reference specific lines of code. You can enable line numbers in Settings or per code block.
- Global setting in Settings → Editor → Show line numbers
- Line numbers appear on the left side of code blocks
- Makes it easy to reference specific lines when discussing code
- Useful for tutorials, documentation, and code reviews
Copy Button
One-Click Copy
Every code block in the preview has a copy button in the top-right corner. Click it to copy the entire code block to your clipboard instantly.
npm install anyslate
Popular Languages
Here are some of the most commonly used language identifiers. AnySlate supports 190+ languages in total.
javascriptAliases: js
typescriptAliases: ts
pythonAliases: py
javacppAliases: c++
csharpAliases: cs
goAliases: golang
rustAliases: rs
rubyAliases: rb
phpswiftkotlinAliases: kt
sqlhtmlcssjsonyamlAliases: yml
markdownAliases: md
bashAliases: shell, sh
powershellAliases: ps1
Need another language?
AnySlate supports 190+ languages including niche languages like COBOL, Fortran, Haskell, Elixir, and many more. Just use the standard language identifier.
Examples
```javascriptExample 1function greet(name) {
const message = `Hello, ${name}!`;
console.log(message);
return message;
}
greet("World");```pythonExample 2def fibonacci(n):
"""Generate Fibonacci sequence up to n"""
a, b = 0, 1
while a < n:
yield a
a, b = b, a + b
for num in fibonacci(100):
print(num)```typescriptExample 3interface User {
id: number;
name: string;
email: string;
}
async function getUser(id: number): Promise<User> {
const response = await fetch(`/api/users/${id}`);
return response.json();
}Tips
Always specify the language
Explicit language identifiers ensure accurate and consistent highlighting.
Use common aliases
Most languages support aliases like 'js' for JavaScript or 'py' for Python.
Format code before pasting
Well-formatted code is easier to read and highlights better.
Use inline code for short snippets
For short code like `const x = 1`, use single backticks instead of code blocks.
Organize your documents?
Learn how to create page hierarchies and use backlinks to build a connected knowledge graph.
Page Hierarchy & Backlinks