mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: switch to shiki
This commit is contained in:
7 files changed
+173
-150
No files matched your search
@@ -2,18 +2,10 @@ import $ from 'jquery';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import { i18n, tpl } from 'vj/utils';
|
||||
|
||||
const highlighterPage = new AutoloadPage('highlighterPage', () => {
|
||||
import('./prismjs').then(({ default: prismjs }) => {
|
||||
export default new AutoloadPage('highlighterPage', () => {
|
||||
import('./shiki').then(({ highlightBlocks }) => {
|
||||
function runHighlight($container) {
|
||||
$container.find('pre code').get().forEach((code) => {
|
||||
const language = ($(code).attr('class') || '').trim();
|
||||
const m = language.match(/language-([a-z0-9]+)(\|[\d,-]+)/);
|
||||
if (m?.[2]) {
|
||||
$(code).parent().attr('data-line', m[2].substring(1));
|
||||
$(code).attr('class', `language-${m[1]}`);
|
||||
}
|
||||
});
|
||||
prismjs.highlightBlocks($container);
|
||||
highlightBlocks($container);
|
||||
$container.find('pre code').get().forEach((code) => {
|
||||
const $code = $(code);
|
||||
const $root = $code.parent().parent();
|
||||
@@ -41,5 +33,3 @@ const highlighterPage = new AutoloadPage('highlighterPage', () => {
|
||||
$(document).on('vjContentNew', (e) => runHighlight($(e.target)));
|
||||
});
|
||||
});
|
||||
|
||||
export default highlighterPage;
|
||||
Reference in new issue
Block a user