diff --git a/oi-wiki-export-typst/package-lock.json b/oi-wiki-export-typst/package-lock.json index 88864d5..e33acbf 100644 --- a/oi-wiki-export-typst/package-lock.json +++ b/oi-wiki-export-typst/package-lock.json @@ -10,12 +10,11 @@ "license": "ISC", "dependencies": { "js-yaml": "^4.1.0", - "remark-details": "^4.1.1", + "remark-details": "^5.0.1", "remark-gfm": "^3.0.1", "remark-math": "^5.1.1", "remark-parse": "^10.0.1", "remark-tabbed": "^0.1.0", - "tiny-glob": "^0.2.9", "to-vfile": "^8.0.0", "unified": "^10.1.2", "unified-stream": "^3.0.0" @@ -92,6 +91,24 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-reference-invalid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/comma-separated-tokens": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", @@ -181,16 +198,6 @@ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, - "node_modules/globalyzer": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz", - "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==" - }, - "node_modules/globrex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", - "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==" - }, "node_modules/hast": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/hast/-/hast-1.0.0.tgz", @@ -225,6 +232,28 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-buffer": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", @@ -247,6 +276,24 @@ "node": ">=4" } }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-hexadecimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -1060,6 +1107,24 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/parse-entities": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-3.1.0.tgz", + "integrity": "sha512-xf2yeHbsfg1vJySsQelVwgtI/67eAndVU05skrr/XN6KFMoVVA95BYrW8y78OfW4jqcuHwB7tlMlLkvbq4WbHQ==", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/property-information": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.3.0.tgz", @@ -1070,14 +1135,15 @@ } }, "node_modules/remark-details": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/remark-details/-/remark-details-4.1.1.tgz", - "integrity": "sha512-D/1LMFEVDILgiwMAVyBqLJ0cdTqzxkKeo2SrIrZrwv+zLO0cVPo/7WuXL4gxDzxdbUol0mNFvk2TA2g4QO8hvA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/remark-details/-/remark-details-5.0.1.tgz", + "integrity": "sha512-Ml2L1qitwn6s5KVNMUyrPUClXzw7q81J7UpFCmkkX3GVMi1zhygrfGK9LpxISft5tTAJqoNhqN1VjXE6AB3TKA==", "dependencies": { "hast": "^1.0.0", "hastscript": "^7.0.2", "mdast-util-from-markdown": "^1.0.2", "mdast-util-to-markdown": "^1.0.0", + "micromark-core-commonmark": "1.0.1", "micromark-factory-space": "^1.0.0", "micromark-util-character": "^1.1.0", "micromark-util-symbol": "^1.0.0", @@ -1086,6 +1152,38 @@ "unist-util-visit": "^4.1.0" } }, + "node_modules/remark-details/node_modules/micromark-core-commonmark": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.1.tgz", + "integrity": "sha512-vEOw8hcQ3nwHkKKNIyP9wBi8M50zjNajtmI+cCUWcVfJS+v5/3WCh4PLKf7PPRZFUutjzl4ZjlHwBWUKfb/SkA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-factory-destination": "^1.0.0", + "micromark-factory-label": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-factory-title": "^1.0.0", + "micromark-factory-whitespace": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-html-tag-name": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "parse-entities": "^3.0.0" + } + }, "node_modules/remark-gfm": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz", @@ -1181,15 +1279,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/tiny-glob": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", - "integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==", - "dependencies": { - "globalyzer": "0.1.0", - "globrex": "^0.1.2" - } - }, "node_modules/to-vfile": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-8.0.0.tgz", diff --git a/oi-wiki-export-typst/package.json b/oi-wiki-export-typst/package.json index c9733ab..794c03f 100644 --- a/oi-wiki-export-typst/package.json +++ b/oi-wiki-export-typst/package.json @@ -10,11 +10,11 @@ "license": "ISC", "dependencies": { "js-yaml": "^4.1.0", - "remark-details": "^4.1.1", - "remark-tabbed": "^0.1.0", + "remark-details": "^5.0.1", "remark-gfm": "^3.0.1", "remark-math": "^5.1.1", "remark-parse": "^10.0.1", + "remark-tabbed": "^0.1.0", "to-vfile": "^8.0.0", "unified": "^10.1.2", "unified-stream": "^3.0.0" diff --git a/oi-wiki-export/package-lock.json b/oi-wiki-export/package-lock.json index e4d1926..fada564 100644 --- a/oi-wiki-export/package-lock.json +++ b/oi-wiki-export/package-lock.json @@ -13,7 +13,7 @@ "js-yaml": "^4.1.0", "node-fetch": "^3.3.2", "rehype-stringify": "^8.0.0", - "remark-details": "^4.1.1", + "remark-details": "^5.0.1", "remark-footnotes": "^4.0.1", "remark-gfm": "^3.0.1", "remark-latex": "file:../remark-latex", @@ -21,7 +21,6 @@ "remark-parse": "^10.0.1", "remark-rehype": "^7.0.0", "remark-tabbed": "^0.1.0", - "tiny-glob": "^0.2.9", "to-vfile": "^8.0.0", "trim": "^1.0.1", "unified": "^10.1.2", @@ -922,6 +921,15 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/character-reference-invalid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/comma-separated-tokens": { "version": "1.0.8", "license": "MIT", @@ -1044,14 +1052,6 @@ "node": ">=12.20.0" } }, - "node_modules/globalyzer": { - "version": "0.1.0", - "license": "MIT" - }, - "node_modules/globrex": { - "version": "0.1.2", - "license": "MIT" - }, "node_modules/hast": { "version": "1.0.0", "license": "MIT" @@ -1150,6 +1150,28 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-buffer": { "version": "2.0.5", "funding": [ @@ -1171,6 +1193,24 @@ "node": ">=4" } }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-hexadecimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-plain-obj": { "version": "4.1.0", "license": "MIT", @@ -2112,6 +2152,33 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/parse-entities": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-3.1.0.tgz", + "integrity": "sha512-xf2yeHbsfg1vJySsQelVwgtI/67eAndVU05skrr/XN6KFMoVVA95BYrW8y78OfW4jqcuHwB7tlMlLkvbq4WbHQ==", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/parse-entities/node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/property-information": { "version": "5.6.0", "license": "MIT", @@ -2135,13 +2202,15 @@ } }, "node_modules/remark-details": { - "version": "4.1.1", - "license": "MIT", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/remark-details/-/remark-details-5.0.1.tgz", + "integrity": "sha512-Ml2L1qitwn6s5KVNMUyrPUClXzw7q81J7UpFCmkkX3GVMi1zhygrfGK9LpxISft5tTAJqoNhqN1VjXE6AB3TKA==", "dependencies": { "hast": "^1.0.0", "hastscript": "^7.0.2", "mdast-util-from-markdown": "^1.0.2", "mdast-util-to-markdown": "^1.0.0", + "micromark-core-commonmark": "1.0.1", "micromark-factory-space": "^1.0.0", "micromark-util-character": "^1.1.0", "micromark-util-symbol": "^1.0.0", @@ -2150,6 +2219,38 @@ "unist-util-visit": "^4.1.0" } }, + "node_modules/remark-details/node_modules/micromark-core-commonmark": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.1.tgz", + "integrity": "sha512-vEOw8hcQ3nwHkKKNIyP9wBi8M50zjNajtmI+cCUWcVfJS+v5/3WCh4PLKf7PPRZFUutjzl4ZjlHwBWUKfb/SkA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-factory-destination": "^1.0.0", + "micromark-factory-label": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-factory-title": "^1.0.0", + "micromark-factory-whitespace": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-html-tag-name": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "parse-entities": "^3.0.0" + } + }, "node_modules/remark-footnotes": { "version": "4.0.1", "license": "MIT", @@ -2281,14 +2382,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/tiny-glob": { - "version": "0.2.9", - "license": "MIT", - "dependencies": { - "globalyzer": "0.1.0", - "globrex": "^0.1.2" - } - }, "node_modules/to-vfile": { "version": "8.0.0", "license": "MIT", diff --git a/oi-wiki-export/package.json b/oi-wiki-export/package.json index ba86884..d7fec73 100644 --- a/oi-wiki-export/package.json +++ b/oi-wiki-export/package.json @@ -14,7 +14,7 @@ "js-yaml": "^4.1.0", "node-fetch": "^3.3.2", "rehype-stringify": "^8.0.0", - "remark-details": "^4.1.1", + "remark-details": "^5.0.1", "remark-footnotes": "^4.0.1", "remark-gfm": "^3.0.1", "remark-latex": "file:../remark-latex", diff --git a/remark-latex/lib/compiler.js b/remark-latex/lib/compiler.js index c8c3c52..42ff11c 100644 --- a/remark-latex/lib/compiler.js +++ b/remark-latex/lib/compiler.js @@ -603,7 +603,7 @@ export default function compiler(options) { case "detailsContainer": { // Pymdown details 语法块 const type = node.attributes.class; - const summary = unquote(parse(node.children[0])); + const summary = parse(node.children[0]); node.children = node.children.slice(1); diff --git a/remark-typst/lib/compiler.js b/remark-typst/lib/compiler.js index dfa274b..df479f4 100644 --- a/remark-typst/lib/compiler.js +++ b/remark-typst/lib/compiler.js @@ -32,11 +32,7 @@ const WARNING = '\x1b[1;33m[WARNING]\x1b[0m ' const ERROR = '\x1b[1;31m[ERROR]\x1b[0m ' const ZWSP = '\u200b' -// Valid types for Pymdown details -const DETAILS_TYPES = [ - 'note', 'abstract', 'info', 'tip', 'success', 'question', - 'warning', 'failure', 'danger', 'bug', 'example', 'quote', -] + const ARTICLE_HEADER = `// Generated by remark-typst #import "../oi-wiki.typ": * ` @@ -381,33 +377,16 @@ function toTypst(tree, options) { const type = node.attributes.class const summary = parse(node.children[0]) - const isTrivial = DETAILS_TYPES.includes(summary) unwrap = node.children && (node.children.length === 2) && (node.children[1].type === 'code') node.children = node.children.slice(1) - let ret - if (type) { - ret = '#details(type: "{0}", unwrap: {1})[{2}][{3}]'.format( - type, - unwrap, - unquote(summary), - all(node, parse).join('') - ) - } else if (isTrivial) { - ret = '#details(type: "{0}", unwrap: {1})[{2}][{3}]'.format( - summary, - unwrap, - capitalize(summary), - all(node, parse).join('') - ) - } else { - ret = '#details(type: "note", unwrap: {0})[{1}][{2}]'.format( - unwrap, - unquote(summary), - all(node, parse).join('') - ) - } + const ret = '#details(type: "{0}", unwrap: {1})[{2}][{3}]'.format( + type, + unwrap, + summary, + all(node, parse).join('') + ) indentPar.pop() // inDetails = false