Skip to content

Commit c3079b9

Browse files
committed
nav.js: horizontal scroll on syntax blocks, highlight example code too
1 parent b8acedc commit c3079b9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

assets/nav.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,21 @@
110110
marker.id = 'ref-cm-loaded';
111111
document.head.appendChild(marker);
112112
const dark = document.body.classList.contains('dark-mode');
113-
document.querySelectorAll('.syntax-block, .impl-block').forEach(el => {
113+
document.querySelectorAll('.syntax-block, .impl-block, .example-code, .code-example').forEach(el => {
114114
const code = el.innerHTML
115115
.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&').trim();
116116
const wrap = document.createElement('div');
117117
el.parentNode.replaceChild(wrap, el);
118-
CodeMirror(wrap, {
118+
const cm = CodeMirror(wrap, {
119119
value: code,
120120
mode: 'cppmode',
121121
theme: dark ? 'cppmode-dark' : 'cppmode',
122122
readOnly: true,
123123
lineNumbers: false,
124+
lineWrapping: false,
124125
});
126+
wrap.style.overflow = 'auto';
127+
wrap.querySelector('.CodeMirror').style.height = 'auto';
125128
});
126129
});
127130
});

0 commit comments

Comments
 (0)