Code Snippets

Updated on March 24, 2026

WP Documentation comes with built-in syntax highlighting powered by Highlight.js โ€” a lightweight, battle-tested syntax highlighter that supports 190+ programming languages and automatically detects the language for most code blocks. Whether youโ€™re documenting JavaScript, Python, HTML, or even obscure languages like R or Elixir, Highlight.js renders beautifully formatted and readable code out of the box.

Features include:

  • โœ… Auto language detection
  • ๐ŸŒˆ Stylish theming with customizable themes
  • ๐Ÿš€ Fast performance, even with large blocks
  • ๐Ÿ”Œ Works seamlessly with Markdown or HTML
  • ๐Ÿ” Copy-to-clipboard support (if integrated)

Below are examples in different languages to demonstrate the full capabilities of syntax highlighting in this theme.

โœ… JavaScript

index.js
// Simple function
function greet(name) {
  console.log(`Hello, ${name}!`);
}

greet("World");

๐Ÿ Python

fibonacci.py
def fibonacci(n):
    a, b = 0, 1
    for _ in range(n):
        print(a)
        a, b = b, a + b

fibonacci(5)

๐Ÿ–ฅ๏ธ Bash

bash
#!/bin/bash

echo "Deploying app..."
npm run build && git push origin main

๐Ÿ“ฆ JSON

config.json
{
  "name": "my-docs-theme",
  "version": "1.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  }
}

๐ŸŒ HTML + CSS

index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Docs Theme</title>
  <style>
    body { background: #fff7ea; color: #000; }
  </style>
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>

โš™๏ธ TypeScript Interface

ts
interface User {
  id: number;
  name: string;
  email?: string;
}

const user: User = { id: 1, name: "Alice" };

๐Ÿ’พ Code Tabs

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
  apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

const account = await client.accounts.create({ name: 'name', type: 'standard' });

console.log(account.id);
package main

import (
	"context"
	"fmt"

	"github.com/cloudflare/cloudflare-go/v3"
	"github.com/cloudflare/cloudflare-go/v3/accounts"
	"github.com/cloudflare/cloudflare-go/v3/option"
)

func main() {
	client := cloudflare.NewClient(
		option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), // defaults to os.LookupEnv("CLOUDFLARE_API_KEY")
		option.WithAPIEmail("user@example.com"),               // defaults to os.LookupEnv("CLOUDFLARE_EMAIL")
	)
	account, err := client.Accounts.New(context.TODO(), accounts.AccountNewParams{
		Name: cloudflare.F("name"),
		Type: cloudflare.F(accounts.AccountNewParamsTypeStandard),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", account.ID)
}
curl https://api.cloudflare.com/client/v4/accounts \
    -H 'Content-Type: application/json' \
    -H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
    -H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
    -d '{
      "name": "name",
      "type": "standard"
    }'
import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_email=os.environ.get("CLOUDFLARE_EMAIL"),  # This is the default and can be omitted
    api_key=os.environ.get("CLOUDFLARE_API_KEY"),  # This is the default and can be omitted
)
account = client.accounts.create(
    name="name",
    type="standard",
)
print(account.id)
$uri = "https://api.cloudflare.com/client/v4/accounts";

$params = @{
  Uri         = $uri
  ContentType = 'application/json'
  Headers     = @{'X-Auth-Email' = "$Env:CLOUDFLARE_EMAIL"; 'X-Auth-Key' = "$Env:CLOUDFLARE_API_KEY"}
  Body        = '{
    "name": "name",
    "type": "standard"
  }'
}

$response = Invoke-WebRequest @params

Next