import $ from 'jquery'; import { AutoloadPage } from 'vj/misc/Page'; import { i18n, tpl } from 'vj/utils'; export default new AutoloadPage('highlighterPage', () => { import('./shiki').then(({ highlightBlocks }) => { function runHighlight($container) { highlightBlocks($container); $container.find('pre code').get().forEach((code) => { const $code = $(code); const $root = $code.parent().parent(); const $typo = $code.closest('.richmedia'); const language = ($(code).attr('class') || '').trim(); const m = language.match(/language-input([0-9]+)/); if (m?.[1]) { const id = +m[1]; if (Number.isSafeInteger(id)) { const $output = ($typo.length ? $typo : $container).find(`pre.language-output${id}`); if ($output.length) { const $c = $(document.createElement('div')).addClass('row'); $root.after($c); $root.prepend($(tpl`