Markdown Code Block Syntax
Basic and advanced syntaxes for Markdown code blocks including line highlighting.
Basic Syntax
Use triple backticks to create a code block:
```language
your code goes here
```Example:
function debounce(func, timeout = 300) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
func.apply(this, args);
}, timeout);
};
}Filename
Add :filename.ext after language to show filename label:
```java:GetRowValue.java
private String[] getRowValue(Integer i) {
// code here
}
```Line Highlighting and Line Numbers
- Add
{numbers}to highlight specific lines - Add
showLineNumbersto display line numbers
```html:index.html {1,4-6,10} showLineNumbers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello world</title>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
```This will highlight lines 1, 4-6, and 10, while showing line numbers.