HTML Example
Highlights HTML markup correctly.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Highlight.js Example</title>
</head>
<body>
<h1>Hello World</h1>
<p class="lead">This is a sample text.</p>
</body>
</html>
JavaScript Example
Highlighting for ES6+ JavaScript code.
import hljs from 'highlight.js';
export function initHighlight() {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
}
// Arrow function example
const greet = (name) => {
return `Hello, ${name}!`;
};
SCSS Example
CSS and SCSS preprocessor highlighting.
$primary-color: #0d6efd;
$border-radius: 0.5rem;
.custom-card {
background-color: white;
border-radius: $border-radius;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
&__header {
color: $primary-color;
font-weight: 600;
}
}