Generate fenced code blocks with language syntax highlighting.
Code blocks display code with proper formatting and optional syntax highlighting, making them essential for technical documentation.
The modern standard using triple backticks:
```javascript
function hello() {
console.log("Hello, world!");
}
```
Advantages: Syntax highlighting, easier to write, language specification
Classic markdown style using 4 spaces or 1 tab:
function hello() {
console.log("Hello, world!");
}
Advantages: Works everywhere, simple syntax
Disadvantages: No syntax highlighting, no language specification
For short code snippets within text, use single backticks:
Use the `console.log()` function to print output.
Specify the language after the opening backticks for syntax highlighting:
```javascript or ```js```python or ```py```html```css```bash or ```shell```json#L10 in URLs#L10-L20```diff```javascript:example.jsjavascript, jspython, pyjavacsharp, cscpp, c++ruby, rbgorust, rshtmlcssjsonyaml, ymlbash, shellsqltypescript, tsmarkdown, mdTo show backticks in code, use more backticks:
`` Use `backticks` for inline code ``
JavaScript:
```javascript const x = 42; ```
Python:
```python
def hello():
print("Hi")
```
Inline:
Use `npm install`