Code Blocks

Syntax highlighting with Shiki, line numbers, highlighting, and more

Jamdesk uses Shiki for beautiful syntax highlighting with support for 100+ languages.

Basic Syntax Highlighting

const greeting = "Hello, Jamdesk!";
console.log(greeting);

Adding a Filename

Show the file path with the title attribute:

src/config.ts
export const config = {
  name: "My Docs",
  theme: "jam"
};

Line Highlighting

Draw attention to specific lines with {1,3-5} syntax:

// This line is highlighted
const config = {
  apiKey: process.env.API_KEY,
  baseUrl: 'https://api.example.com', // highlighted
  timeout: 5000,                       // highlighted
  retries: 3,                          // highlighted
};

Line Numbers

Add line numbers with showLineNumbers:

def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n - 1) + fibonacci(n - 2)

Custom Start Line

Start numbering from a specific line:

func processRequest(ctx context.Context) error {
    // This is line 42
    return nil
}

Combined Features

Use multiple features together:

api/client.ts showLineNumbers {3-5}
import axios from 'axios';

const client = axios.create({
  baseURL: process.env.API_URL,
  timeout: 10000,
});

export default client;

Code Groups

Show the same code in multiple languages:

curl -X POST https://api.example.com/posts \
  -H "Authorization: Bearer $API_KEY"

Available Themes

Configure syntax highlighting themes in docs.json:

docs.json
{
  "styling": {
    "codeblocks": {
      "theme": {
        "light": "github-light",
        "dark": "github-dark"
      }
    }
  }
}

Popular themes include:

  • GitHub: github-dark, github-light, github-dark-default, github-light-default
  • Dark themes: tokyo-night, one-dark-pro, dracula, nord, vitesse-dark
  • Light themes: vitesse-light, min-light
  • Catppuccin: catppuccin-mocha, catppuccin-latte

CSS Variables Theme

For complete control over syntax highlighting colors, use the CSS Variables theme:

docs.json
{
  "styling": {
    "codeblocks": {
      "theme": "css-variables"
    }
  }
}

Then customize colors in your custom.css:

custom.css
:root {
  --jd-token-keyword: #ff7b72;
  --jd-token-string: #a5d6ff;
  --jd-token-comment: #8b949e;
  --jd-token-function: #d2a8ff;
  --jd-token-constant: #79c0ff;
  --jd-token-parameter: #ffa657;
}
VariableDescription
--jd-color-textDefault text color
--jd-color-backgroundCode block background
--jd-token-keywordKeywords (if, const, function)
--jd-token-stringString literals
--jd-token-commentComments
--jd-token-functionFunction names
--jd-token-constantConstants
--jd-token-parameterFunction parameters
--jd-token-punctuationBrackets, commas
--jd-token-linkURLs and links