Skip to content

Commit 8fbc84d

Browse files
0xranxclaude
andcommitted
Fix syntax highlighting: langPrefix 'hljs' class was blocking highlight.js
highlight.js v11 skips elements that already have the 'hljs' class. The previous langPrefix 'hljs language-' caused marked to add 'hljs' to code elements before highlight.js ran, so all tagged blocks (```bash, etc.) were silently skipped. Changed langPrefix to 'language-' to fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b9e9cc3 commit 8fbc84d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎site/brief.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
'startup-builder':'biz','fullstack-dev':'combo','startup-kit':'combo'
151151
};
152152

153-
marked.setOptions({ langPrefix: 'hljs language-' });
153+
marked.setOptions({ langPrefix: 'language-' });
154154

155155
async function loadBrief(){
156156
const params=new URLSearchParams(location.search);
@@ -250,7 +250,7 @@ <h2>Knowledge <span class="count">${knowledgeList.length}</span></h2>
250250

251251
// Apply syntax highlighting with auto-detection for untagged blocks
252252
document.querySelectorAll('pre code').forEach(block => {
253-
if (!block.className || block.className === 'hljs') {
253+
if (!block.className) {
254254
const result = hljs.highlightAuto(block.textContent);
255255
block.innerHTML = result.value;
256256
block.classList.add('hljs', 'language-' + (result.language || 'plaintext'));

‎site/docs.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ <h4>Reference</h4>
118118

119119
<script>
120120
// Configure marked to add language class to code blocks
121-
marked.setOptions({ langPrefix: 'hljs language-' });
121+
marked.setOptions({ langPrefix: 'language-' });
122122

123123
const BASE = 'https://raw.githubusercontent.com/0xranx/agentbrief/main/';
124124
const paths = {
@@ -151,7 +151,7 @@ <h4>Reference</h4>
151151
// Apply syntax highlighting to all code blocks
152152
container.querySelectorAll('pre code').forEach(block => {
153153
// Auto-detect language for untagged code blocks
154-
if (!block.className || block.className === 'hljs') {
154+
if (!block.className) {
155155
const result = hljs.highlightAuto(block.textContent);
156156
block.innerHTML = result.value;
157157
block.classList.add('hljs', 'language-' + (result.language || 'plaintext'));

0 commit comments

Comments
 (0)