Lightweight Syntax Highlighter
// 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)}`);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
.container {
max-width: 1200px;
margin: 0 auto;
padding: 24px;
}
@media (min-width: 768px) {
.container {
padding: 32px;
}
}
./prism/prism.css and ./prism/prism.jslanguage-javascript to <code> elements