Prism.js

Lightweight Syntax Highlighter

JavaScript Example

// Prism.js automatically highlights this code
function calculateTotal(items) {
  return items.reduce((sum, item) => {
    return sum + item.price * item.quantity;
  }, 0);
}

const cart = [
  { name: 'Product A', price: 29.99, quantity: 2 },
  { name: 'Product B', price: 49.99, quantity: 1 }
];

const total = calculateTotal(cart);
console.log(`Total: $${total.toFixed(2)}`);

HTML Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example</title>
</head>
<body>
  <h1>Hello, World!</h1>
</body>
</html>

CSS Example

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

@media (min-width: 768px) {
  .container {
    padding: 32px;
  }
}

Features

Usage