From 006b15b467a5cd835a6eab1b49023100bdc8f2e6 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 13 Oct 2023 19:32:56 +0200 Subject: refactor(components): rewrite Code component and usePrism hook * move Prism styles to Sass placeholders to avoid repeats * let usePrism consumer define its plugins (remove default ones) * remove `plugins` prop from Code component * add new props to Code component to let consumer configure plugins (and handle plugin list from the given options) However there are some problems with Prism plugins: line-highlight and treeview does not seems to be loaded. I don't want to use Babel instead of SWC so I have no solution for now. --- public/prism/prism-asciidoc.min.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'public/prism/prism-asciidoc.min.js') diff --git a/public/prism/prism-asciidoc.min.js b/public/prism/prism-asciidoc.min.js index 19af164..8aaee24 100644 --- a/public/prism/prism-asciidoc.min.js +++ b/public/prism/prism-asciidoc.min.js @@ -19,11 +19,8 @@ 'attr-value': /(?!^\s+$).+/, }, }, - a = (t.languages.asciidoc = { - 'comment-block': { - pattern: /^(\/{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1/m, - alias: 'comment', - }, + i = (t.languages.asciidoc = { + 'comment-block': { pattern: /^(\/{4,})$[\s\S]*?^\1/m, alias: 'comment' }, table: { pattern: /^\|={3,}(?:(?:\r?\n|\r(?!\n)).*)*?(?:\r?\n|\r)\|={3,}$/m, inside: { @@ -36,16 +33,15 @@ }, }, 'passthrough-block': { - pattern: /^(\+{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m, + pattern: /^(\+{4,})$[\s\S]*?^\1$/m, inside: { punctuation: /^\++|\++$/ }, }, 'literal-block': { - pattern: /^(-{4,}|\.{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m, + pattern: /^(-{4,}|\.{4,})$[\s\S]*?^\1$/m, inside: { punctuation: /^(?:-+|\.+)|(?:-+|\.+)$/ }, }, 'other-block': { - pattern: - /^(--|\*{4,}|_{4,}|={4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m, + pattern: /^(--|\*{4,}|_{4,}|={4,})$[\s\S]*?^\1$/m, inside: { punctuation: /^(?:-+|\*+|_+|=+)|(?:-+|\*+|_+|=+)$/ }, }, 'list-punctuation': { @@ -135,21 +131,21 @@ alias: 'punctuation', }, }); - function i(t) { - for (var n = {}, i = 0, e = (t = t.split(' ')).length; i < e; i++) - n[t[i]] = a[t[i]]; + function e(t) { + for (var n = {}, e = 0, a = (t = t.split(' ')).length; e < a; e++) + n[t[e]] = i[t[e]]; return n; } - (n.inside.interpreted.inside.rest = i('macro inline replacement entity')), - (a['passthrough-block'].inside.rest = i('macro')), - (a['literal-block'].inside.rest = i('callout')), - (a.table.inside.rest = i( + (n.inside.interpreted.inside.rest = e('macro inline replacement entity')), + (i['passthrough-block'].inside.rest = e('macro')), + (i['literal-block'].inside.rest = e('callout')), + (i.table.inside.rest = e( 'comment-block passthrough-block literal-block other-block list-punctuation indented-block comment title attribute-entry attributes hr page-break admonition list-label callout macro inline replacement entity line-continuation' )), - (a['other-block'].inside.rest = i( + (i['other-block'].inside.rest = e( 'table list-punctuation indented-block comment attribute-entry attributes hr page-break admonition list-label macro inline replacement entity line-continuation' )), - (a.title.inside.rest = i('macro inline replacement entity')), + (i.title.inside.rest = e('macro inline replacement entity')), t.hooks.add('wrap', function (t) { 'entity' === t.type && (t.attributes.title = t.content.replace(/&/, '&')); -- cgit v1.2.3