Skip to content

Commit 6092173

Browse files
committed
"fix" broken callouts in code blocks
1 parent f6adc65 commit 6092173

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/js/vendor/highlight.bundle.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737
// hljs.registerLanguage('swift', require('highlight.js/lib/languages/swift'))
3838
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'))
3939
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'))
40+
// Register the plugin
41+
hljs.addPlugin({
42+
// https://gitlab.com/antora/antora-ui-default/-/issues/203
43+
// https://github.com/asciidoctor/asciidoctor/issues/3976#issuecomment-3449797396
44+
'after:highlight': (result) => {
45+
const callout = '<i class="conum" data-value="$1"></i><b>$1</b>'
46+
result.value = result.value
47+
.replaceAll(/<span class="hljs-string">\((\d+)\)<\/span>/g, callout) // YAML
48+
.replaceAll(/\(<span class="hljs-number">([1-9]|1[0-9]|20)<\/span>\)$/gm, callout) // Java
49+
.replaceAll(/\(([1-9]|1[0-9]|20)\)$/gm, callout)
50+
},
51+
})
4052
;[].slice.call(document.querySelectorAll('pre code.hljs[data-lang]')).forEach(function (node) {
4153
hljs.highlightElement(node)
4254
})

0 commit comments

Comments
 (0)