Testing the script tag integration via CDN. All code blocks below are automatically highlighted using tree-sitter grammars loaded on demand.

Errors

Rust

fn main() {
    let message = "Hello, world!";
    println!("{}", message);
}

struct Point {
    x: f64,
    y: f64,
}

impl Point {
    fn distance(&self, other: &Point) -> f64 {
        ((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt()
    }
}

JavaScript

async function fetchData(url) {
    const response = await fetch(url);
    const data = await response.json();
    return data.items.map(item => ({
        id: item.id,
        name: item.name.toUpperCase()
    }));
}

class EventEmitter {
    constructor() {
        this.events = new Map();
    }

    on(event, callback) {
        if (!this.events.has(event)) {
            this.events.set(event, []);
        }
        this.events.get(event).push(callback);
    }
}

Python

from dataclasses import dataclass
from typing import List, Optional

@dataclass
class User:
    name: str
    email: str
    age: Optional[int] = None

def process_users(users: List[User]) -> dict:
    return {
        user.name: user.email
        for user in users
        if user.age is None or user.age >= 18
    }

Auto-detect (no language specified)

SELECT u.name, u.email, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at > '2024-01-01'
GROUP BY u.id
HAVING order_count > 5
ORDER BY order_count DESC;