@aiquants/html-to-markdown 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/{core-C45e4gDg.js → core-0q2nkcWH.js} +955 -1053
- package/dist/core-DUdcm-c8.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +8 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +49 -17
- package/dist/src/converter.d.ts +7 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/plugins/index.d.ts +1 -1
- package/dist/src/types.d.ts +45 -1
- package/dist/tests/browser-100.test.d.ts +1 -0
- package/dist/tests/browser-coverage.test.d.ts +1 -0
- package/dist/tests/converter-coverage.test.d.ts +1 -0
- package/dist/tests/readme-usage.test.d.ts +1 -0
- package/dist/tests/rehype-absolute-links-coverage.test.d.ts +1 -0
- package/dist/tests/rehype-sanitize-html-coverage.test.d.ts +1 -0
- package/package.json +1 -1
- package/dist/core-D1CksXT5.cjs +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { Window } from "happy-dom";
|
|
2
|
+
const window = new Window();
|
|
3
|
+
Object.assign(global, {
|
|
4
|
+
document: window.document,
|
|
5
|
+
window,
|
|
6
|
+
self: window
|
|
7
|
+
});
|
|
1
8
|
import { chromium } from "playwright";
|
|
2
9
|
const messages = {
|
|
3
10
|
"ja-JP": {
|
|
4
11
|
error_url_required: "エラー: 変換対象のURLを引数で指定してください。",
|
|
5
|
-
usage: "使用法: node dist/main.js <URL> [--locale <ロケール>]",
|
|
6
|
-
example: "例: node dist/main.js https://ja.wikipedia.org/wiki/Node.js --locale ja-JP",
|
|
12
|
+
usage: "使用法: node dist/main.js <URL> [--output <ファイルパス>] [--locale <ロケール>]",
|
|
13
|
+
example: "例: node dist/main.js https://ja.wikipedia.org/wiki/Node.js -o output.md --locale ja-JP",
|
|
7
14
|
cli_start: "🚀 コマンドラインから処理を開始します...",
|
|
8
15
|
cli_url: " - URL: {url}",
|
|
9
16
|
cli_locale: " - Locale: {locale}",
|
|
17
|
+
cli_output: " - Output: {path}",
|
|
10
18
|
success_save: "✅ Markdownファイルが正常に保存されました。",
|
|
11
19
|
success_path: " -> {path}",
|
|
12
20
|
error_app: "❌ アプリケーションの実行中にエラーが発生しました。",
|
|
@@ -16,15 +24,17 @@ const messages = {
|
|
|
16
24
|
playwright_close: "✅ ブラウザを閉じました。",
|
|
17
25
|
playwright_error: "PlaywrightでのHTML取得中にエラーが発生しました:",
|
|
18
26
|
convert_start: "🔄 HTMLからMarkdownへの変換を開始...",
|
|
19
|
-
convert_success: "✅ Markdown変換が完了しました。"
|
|
27
|
+
convert_success: "✅ Markdown変換が完了しました。",
|
|
28
|
+
url_parse_error: "URLのパースに失敗しました:"
|
|
20
29
|
},
|
|
21
30
|
"en-US": {
|
|
22
31
|
error_url_required: "Error: Please specify the URL to convert as an argument.",
|
|
23
|
-
usage: "Usage: node dist/main.js <URL> [--locale <locale>]",
|
|
24
|
-
example: "Example: node dist/main.js https://en.wikipedia.org/wiki/Node.js --locale en-US",
|
|
32
|
+
usage: "Usage: node dist/main.js <URL> [--output <file path>] [--locale <locale>]",
|
|
33
|
+
example: "Example: node dist/main.js https://en.wikipedia.org/wiki/Node.js -o output.md --locale en-US",
|
|
25
34
|
cli_start: "🚀 Starting process from command line...",
|
|
26
35
|
cli_url: " - URL: {url}",
|
|
27
36
|
cli_locale: " - Locale: {locale}",
|
|
37
|
+
cli_output: " - Output: {path}",
|
|
28
38
|
success_save: "✅ Markdown file saved successfully.",
|
|
29
39
|
success_path: " -> {path}",
|
|
30
40
|
error_app: "❌ An error occurred during application execution.",
|
|
@@ -34,7 +44,8 @@ const messages = {
|
|
|
34
44
|
playwright_close: "✅ Browser closed.",
|
|
35
45
|
playwright_error: "An error occurred while fetching HTML with Playwright:",
|
|
36
46
|
convert_start: "🔄 Starting HTML to Markdown conversion...",
|
|
37
|
-
convert_success: "✅ Markdown conversion completed."
|
|
47
|
+
convert_success: "✅ Markdown conversion completed.",
|
|
48
|
+
url_parse_error: "Failed to parse URL:"
|
|
38
49
|
}
|
|
39
50
|
};
|
|
40
51
|
const getMessage = (locale, key2, replacements) => {
|
|
@@ -68,6 +79,55 @@ const getHtmlWithPlaywright = async (url, locale) => {
|
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
81
|
};
|
|
82
|
+
const regex = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g;
|
|
83
|
+
const own$a = Object.hasOwnProperty;
|
|
84
|
+
class BananaSlug {
|
|
85
|
+
/**
|
|
86
|
+
* Create a new slug class.
|
|
87
|
+
*/
|
|
88
|
+
constructor() {
|
|
89
|
+
this.occurrences;
|
|
90
|
+
this.reset();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate a unique slug.
|
|
94
|
+
*
|
|
95
|
+
* Tracks previously generated slugs: repeated calls with the same value
|
|
96
|
+
* will result in different slugs.
|
|
97
|
+
* Use the `slug` function to get same slugs.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} value
|
|
100
|
+
* String of text to slugify
|
|
101
|
+
* @param {boolean} [maintainCase=false]
|
|
102
|
+
* Keep the current case, otherwise make all lowercase
|
|
103
|
+
* @return {string}
|
|
104
|
+
* A unique slug string
|
|
105
|
+
*/
|
|
106
|
+
slug(value, maintainCase) {
|
|
107
|
+
const self2 = this;
|
|
108
|
+
let result = slug(value, maintainCase === true);
|
|
109
|
+
const originalSlug = result;
|
|
110
|
+
while (own$a.call(self2.occurrences, result)) {
|
|
111
|
+
self2.occurrences[originalSlug]++;
|
|
112
|
+
result = originalSlug + "-" + self2.occurrences[originalSlug];
|
|
113
|
+
}
|
|
114
|
+
self2.occurrences[result] = 0;
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Reset - Forget all previous slugs
|
|
119
|
+
*
|
|
120
|
+
* @return void
|
|
121
|
+
*/
|
|
122
|
+
reset() {
|
|
123
|
+
this.occurrences = /* @__PURE__ */ Object.create(null);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function slug(value, maintainCase) {
|
|
127
|
+
if (typeof value !== "string") return "";
|
|
128
|
+
if (!maintainCase) value = value.toLowerCase();
|
|
129
|
+
return value.replace(regex, "").replace(/ /g, "-");
|
|
130
|
+
}
|
|
71
131
|
const htmlVoidElements = [
|
|
72
132
|
"area",
|
|
73
133
|
"base",
|
|
@@ -207,7 +267,7 @@ function mark$1(values, key2, value) {
|
|
|
207
267
|
values[key2] = value;
|
|
208
268
|
}
|
|
209
269
|
}
|
|
210
|
-
function create$
|
|
270
|
+
function create$4(definition2) {
|
|
211
271
|
const properties = {};
|
|
212
272
|
const normals = {};
|
|
213
273
|
for (const [property, value] of Object.entries(definition2.properties)) {
|
|
@@ -226,7 +286,7 @@ function create$5(definition2) {
|
|
|
226
286
|
}
|
|
227
287
|
return new Schema$1(properties, normals, definition2.space);
|
|
228
288
|
}
|
|
229
|
-
const aria$1 = create$
|
|
289
|
+
const aria$1 = create$4({
|
|
230
290
|
properties: {
|
|
231
291
|
ariaActiveDescendant: null,
|
|
232
292
|
ariaAtomic: booleanish$1,
|
|
@@ -288,7 +348,7 @@ function caseSensitiveTransform$1(attributes, attribute) {
|
|
|
288
348
|
function caseInsensitiveTransform$1(attributes, property) {
|
|
289
349
|
return caseSensitiveTransform$1(attributes, property.toLowerCase());
|
|
290
350
|
}
|
|
291
|
-
const html$6 = create$
|
|
351
|
+
const html$6 = create$4({
|
|
292
352
|
attributes: {
|
|
293
353
|
acceptcharset: "accept-charset",
|
|
294
354
|
classname: "class",
|
|
@@ -650,7 +710,7 @@ const html$6 = create$5({
|
|
|
650
710
|
space: "html",
|
|
651
711
|
transform: caseInsensitiveTransform$1
|
|
652
712
|
});
|
|
653
|
-
const svg$3 = create$
|
|
713
|
+
const svg$3 = create$4({
|
|
654
714
|
attributes: {
|
|
655
715
|
accentHeight: "accent-height",
|
|
656
716
|
alignmentBaseline: "alignment-baseline",
|
|
@@ -1210,7 +1270,7 @@ const svg$3 = create$5({
|
|
|
1210
1270
|
space: "svg",
|
|
1211
1271
|
transform: caseSensitiveTransform$1
|
|
1212
1272
|
});
|
|
1213
|
-
const xlink$1 = create$
|
|
1273
|
+
const xlink$1 = create$4({
|
|
1214
1274
|
properties: {
|
|
1215
1275
|
xLinkActuate: null,
|
|
1216
1276
|
xLinkArcRole: null,
|
|
@@ -1225,13 +1285,13 @@ const xlink$1 = create$5({
|
|
|
1225
1285
|
return "xlink:" + property.slice(5).toLowerCase();
|
|
1226
1286
|
}
|
|
1227
1287
|
});
|
|
1228
|
-
const xmlns$1 = create$
|
|
1288
|
+
const xmlns$1 = create$4({
|
|
1229
1289
|
attributes: { xmlnsxlink: "xmlns:xlink" },
|
|
1230
1290
|
properties: { xmlnsXLink: null, xmlns: null },
|
|
1231
1291
|
space: "xmlns",
|
|
1232
1292
|
transform: caseInsensitiveTransform$1
|
|
1233
1293
|
});
|
|
1234
|
-
const xml$1 = create$
|
|
1294
|
+
const xml$1 = create$4({
|
|
1235
1295
|
properties: { xmlBase: null, xmlLang: null, xmlSpace: null },
|
|
1236
1296
|
space: "xml",
|
|
1237
1297
|
transform(_, property) {
|
|
@@ -1274,15 +1334,15 @@ function camelcase$2($0) {
|
|
|
1274
1334
|
}
|
|
1275
1335
|
const html$5 = merge$1([aria$1, html$6, xlink$1, xmlns$1, xml$1], "html");
|
|
1276
1336
|
const svg$2 = merge$1([aria$1, svg$3, xlink$1, xmlns$1, xml$1], "svg");
|
|
1277
|
-
const own$
|
|
1337
|
+
const own$9 = {}.hasOwnProperty;
|
|
1278
1338
|
function zwitch(key2, options) {
|
|
1279
1339
|
const settings = options || {};
|
|
1280
1340
|
function one2(value, ...parameters) {
|
|
1281
1341
|
let fn = one2.invalid;
|
|
1282
1342
|
const handlers2 = one2.handlers;
|
|
1283
|
-
if (value && own$
|
|
1343
|
+
if (value && own$9.call(value, key2)) {
|
|
1284
1344
|
const id = String(value[key2]);
|
|
1285
|
-
fn = own$
|
|
1345
|
+
fn = own$9.call(handlers2, id) ? handlers2[id] : one2.unknown;
|
|
1286
1346
|
}
|
|
1287
1347
|
if (fn) {
|
|
1288
1348
|
return fn.call(this, value, ...parameters);
|
|
@@ -1723,18 +1783,18 @@ const dangerous = [
|
|
|
1723
1783
|
"para",
|
|
1724
1784
|
"times"
|
|
1725
1785
|
];
|
|
1726
|
-
const own$
|
|
1786
|
+
const own$8 = {}.hasOwnProperty;
|
|
1727
1787
|
const characters = {};
|
|
1728
1788
|
let key;
|
|
1729
1789
|
for (key in characterEntitiesHtml4) {
|
|
1730
|
-
if (own$
|
|
1790
|
+
if (own$8.call(characterEntitiesHtml4, key)) {
|
|
1731
1791
|
characters[characterEntitiesHtml4[key]] = key;
|
|
1732
1792
|
}
|
|
1733
1793
|
}
|
|
1734
1794
|
const notAlphanumericRegex = /[^\dA-Za-z]/;
|
|
1735
1795
|
function toNamed(code2, next2, omit, attribute) {
|
|
1736
1796
|
const character = String.fromCharCode(code2);
|
|
1737
|
-
if (own$
|
|
1797
|
+
if (own$8.call(characters, character)) {
|
|
1738
1798
|
const name = characters[character];
|
|
1739
1799
|
const value = "&" + name;
|
|
1740
1800
|
if (omit && characterEntitiesLegacy.includes(name) && !dangerous.includes(name) && (!attribute || next2 && next2 !== 61 && notAlphanumericRegex.test(String.fromCharCode(next2)))) {
|
|
@@ -1860,11 +1920,11 @@ function siblings(increment2) {
|
|
|
1860
1920
|
return next2;
|
|
1861
1921
|
}
|
|
1862
1922
|
}
|
|
1863
|
-
const own$
|
|
1923
|
+
const own$7 = {}.hasOwnProperty;
|
|
1864
1924
|
function omission(handlers2) {
|
|
1865
1925
|
return omit;
|
|
1866
1926
|
function omit(node2, index2, parent) {
|
|
1867
|
-
return own$
|
|
1927
|
+
return own$7.call(handlers2, node2.tagName) && handlers2[node2.tagName](node2, index2, parent);
|
|
1868
1928
|
}
|
|
1869
1929
|
}
|
|
1870
1930
|
const closing = omission({
|
|
@@ -2149,11 +2209,11 @@ function unknown$2(node_) {
|
|
|
2149
2209
|
);
|
|
2150
2210
|
throw new Error("Cannot compile unknown node `" + node2.type + "`");
|
|
2151
2211
|
}
|
|
2152
|
-
const emptyOptions$
|
|
2212
|
+
const emptyOptions$7 = {};
|
|
2153
2213
|
const emptyCharacterReferences = {};
|
|
2154
2214
|
const emptyChildren = [];
|
|
2155
2215
|
function toHtml(tree, options) {
|
|
2156
|
-
const options_ = options || emptyOptions$
|
|
2216
|
+
const options_ = options || emptyOptions$7;
|
|
2157
2217
|
const quote = options_.quote || '"';
|
|
2158
2218
|
const alternative = quote === '"' ? "'" : '"';
|
|
2159
2219
|
if (quote !== '"' && quote !== "'") {
|
|
@@ -2203,665 +2263,65 @@ function all$8(parent) {
|
|
|
2203
2263
|
}
|
|
2204
2264
|
return results.join("");
|
|
2205
2265
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2210
|
-
const
|
|
2211
|
-
const
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
case VOID:
|
|
2229
|
-
return as(value, index2);
|
|
2230
|
-
case ARRAY: {
|
|
2231
|
-
const arr = as([], index2);
|
|
2232
|
-
for (const index3 of value)
|
|
2233
|
-
arr.push(unpair(index3));
|
|
2234
|
-
return arr;
|
|
2235
|
-
}
|
|
2236
|
-
case OBJECT: {
|
|
2237
|
-
const object = as({}, index2);
|
|
2238
|
-
for (const [key2, index3] of value)
|
|
2239
|
-
object[unpair(key2)] = unpair(index3);
|
|
2240
|
-
return object;
|
|
2241
|
-
}
|
|
2242
|
-
case DATE:
|
|
2243
|
-
return as(new Date(value), index2);
|
|
2244
|
-
case REGEXP: {
|
|
2245
|
-
const { source, flags } = value;
|
|
2246
|
-
return as(new RegExp(source, flags), index2);
|
|
2247
|
-
}
|
|
2248
|
-
case MAP: {
|
|
2249
|
-
const map2 = as(/* @__PURE__ */ new Map(), index2);
|
|
2250
|
-
for (const [key2, index3] of value)
|
|
2251
|
-
map2.set(unpair(key2), unpair(index3));
|
|
2252
|
-
return map2;
|
|
2253
|
-
}
|
|
2254
|
-
case SET: {
|
|
2255
|
-
const set = as(/* @__PURE__ */ new Set(), index2);
|
|
2256
|
-
for (const index3 of value)
|
|
2257
|
-
set.add(unpair(index3));
|
|
2258
|
-
return set;
|
|
2259
|
-
}
|
|
2260
|
-
case ERROR: {
|
|
2261
|
-
const { name, message } = value;
|
|
2262
|
-
return as(new env[name](message), index2);
|
|
2263
|
-
}
|
|
2264
|
-
case BIGINT:
|
|
2265
|
-
return as(BigInt(value), index2);
|
|
2266
|
-
case "BigInt":
|
|
2267
|
-
return as(Object(BigInt(value)), index2);
|
|
2268
|
-
case "ArrayBuffer":
|
|
2269
|
-
return as(new Uint8Array(value).buffer, value);
|
|
2270
|
-
case "DataView": {
|
|
2271
|
-
const { buffer } = new Uint8Array(value);
|
|
2272
|
-
return as(new DataView(buffer), value);
|
|
2266
|
+
function ok$1() {
|
|
2267
|
+
}
|
|
2268
|
+
const search = /[#.]/g;
|
|
2269
|
+
function parseSelector(selector, defaultTagName) {
|
|
2270
|
+
const value = selector || "";
|
|
2271
|
+
const props = {};
|
|
2272
|
+
let start = 0;
|
|
2273
|
+
let previous2;
|
|
2274
|
+
let tagName;
|
|
2275
|
+
while (start < value.length) {
|
|
2276
|
+
search.lastIndex = start;
|
|
2277
|
+
const match = search.exec(value);
|
|
2278
|
+
const subvalue = value.slice(start, match ? match.index : value.length);
|
|
2279
|
+
if (subvalue) {
|
|
2280
|
+
if (!previous2) {
|
|
2281
|
+
tagName = subvalue;
|
|
2282
|
+
} else if (previous2 === "#") {
|
|
2283
|
+
props.id = subvalue;
|
|
2284
|
+
} else if (Array.isArray(props.className)) {
|
|
2285
|
+
props.className.push(subvalue);
|
|
2286
|
+
} else {
|
|
2287
|
+
props.className = [subvalue];
|
|
2273
2288
|
}
|
|
2289
|
+
start += subvalue.length;
|
|
2290
|
+
}
|
|
2291
|
+
if (match) {
|
|
2292
|
+
previous2 = match[0];
|
|
2293
|
+
start++;
|
|
2274
2294
|
}
|
|
2275
|
-
return as(new env[type](value), index2);
|
|
2276
|
-
};
|
|
2277
|
-
return unpair;
|
|
2278
|
-
};
|
|
2279
|
-
const deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
|
|
2280
|
-
const EMPTY = "";
|
|
2281
|
-
const { toString: toString$2 } = {};
|
|
2282
|
-
const { keys } = Object;
|
|
2283
|
-
const typeOf = (value) => {
|
|
2284
|
-
const type = typeof value;
|
|
2285
|
-
if (type !== "object" || !value)
|
|
2286
|
-
return [PRIMITIVE, type];
|
|
2287
|
-
const asString = toString$2.call(value).slice(8, -1);
|
|
2288
|
-
switch (asString) {
|
|
2289
|
-
case "Array":
|
|
2290
|
-
return [ARRAY, EMPTY];
|
|
2291
|
-
case "Object":
|
|
2292
|
-
return [OBJECT, EMPTY];
|
|
2293
|
-
case "Date":
|
|
2294
|
-
return [DATE, EMPTY];
|
|
2295
|
-
case "RegExp":
|
|
2296
|
-
return [REGEXP, EMPTY];
|
|
2297
|
-
case "Map":
|
|
2298
|
-
return [MAP, EMPTY];
|
|
2299
|
-
case "Set":
|
|
2300
|
-
return [SET, EMPTY];
|
|
2301
|
-
case "DataView":
|
|
2302
|
-
return [ARRAY, asString];
|
|
2303
2295
|
}
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
const shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol");
|
|
2311
|
-
const serializer = (strict, json, $2, _) => {
|
|
2312
|
-
const as = (out, value) => {
|
|
2313
|
-
const index2 = _.push(out) - 1;
|
|
2314
|
-
$2.set(value, index2);
|
|
2315
|
-
return index2;
|
|
2296
|
+
return {
|
|
2297
|
+
type: "element",
|
|
2298
|
+
// @ts-expect-error: tag name is parsed.
|
|
2299
|
+
tagName: tagName || defaultTagName || "div",
|
|
2300
|
+
properties: props,
|
|
2301
|
+
children: []
|
|
2316
2302
|
};
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2340
|
-
case ARRAY: {
|
|
2341
|
-
if (type) {
|
|
2342
|
-
let spread = value;
|
|
2343
|
-
if (type === "DataView") {
|
|
2344
|
-
spread = new Uint8Array(value.buffer);
|
|
2345
|
-
} else if (type === "ArrayBuffer") {
|
|
2346
|
-
spread = new Uint8Array(value);
|
|
2347
|
-
}
|
|
2348
|
-
return as([type, [...spread]], value);
|
|
2349
|
-
}
|
|
2350
|
-
const arr = [];
|
|
2351
|
-
const index2 = as([TYPE, arr], value);
|
|
2352
|
-
for (const entry of value)
|
|
2353
|
-
arr.push(pair(entry));
|
|
2354
|
-
return index2;
|
|
2355
|
-
}
|
|
2356
|
-
case OBJECT: {
|
|
2357
|
-
if (type) {
|
|
2358
|
-
switch (type) {
|
|
2359
|
-
case "BigInt":
|
|
2360
|
-
return as([type, value.toString()], value);
|
|
2361
|
-
case "Boolean":
|
|
2362
|
-
case "Number":
|
|
2363
|
-
case "String":
|
|
2364
|
-
return as([type, value.valueOf()], value);
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
if (json && "toJSON" in value)
|
|
2368
|
-
return pair(value.toJSON());
|
|
2369
|
-
const entries = [];
|
|
2370
|
-
const index2 = as([TYPE, entries], value);
|
|
2371
|
-
for (const key2 of keys(value)) {
|
|
2372
|
-
if (strict || !shouldSkip(typeOf(value[key2])))
|
|
2373
|
-
entries.push([pair(key2), pair(value[key2])]);
|
|
2374
|
-
}
|
|
2375
|
-
return index2;
|
|
2376
|
-
}
|
|
2377
|
-
case DATE:
|
|
2378
|
-
return as([TYPE, value.toISOString()], value);
|
|
2379
|
-
case REGEXP: {
|
|
2380
|
-
const { source, flags } = value;
|
|
2381
|
-
return as([TYPE, { source, flags }], value);
|
|
2382
|
-
}
|
|
2383
|
-
case MAP: {
|
|
2384
|
-
const entries = [];
|
|
2385
|
-
const index2 = as([TYPE, entries], value);
|
|
2386
|
-
for (const [key2, entry] of value) {
|
|
2387
|
-
if (strict || !(shouldSkip(typeOf(key2)) || shouldSkip(typeOf(entry))))
|
|
2388
|
-
entries.push([pair(key2), pair(entry)]);
|
|
2389
|
-
}
|
|
2390
|
-
return index2;
|
|
2391
|
-
}
|
|
2392
|
-
case SET: {
|
|
2393
|
-
const entries = [];
|
|
2394
|
-
const index2 = as([TYPE, entries], value);
|
|
2395
|
-
for (const entry of value) {
|
|
2396
|
-
if (strict || !shouldSkip(typeOf(entry)))
|
|
2397
|
-
entries.push(pair(entry));
|
|
2398
|
-
}
|
|
2399
|
-
return index2;
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
const { message } = value;
|
|
2403
|
-
return as([TYPE, { name: type, message }], value);
|
|
2404
|
-
};
|
|
2405
|
-
return pair;
|
|
2406
|
-
};
|
|
2407
|
-
const serialize$1 = (value, { json, lossy } = {}) => {
|
|
2408
|
-
const _ = [];
|
|
2409
|
-
return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
|
|
2410
|
-
};
|
|
2411
|
-
const structuredClone$1 = typeof structuredClone === "function" ? (
|
|
2412
|
-
/* c8 ignore start */
|
|
2413
|
-
(any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize$1(any, options)) : structuredClone(any)
|
|
2414
|
-
) : (any, options) => deserialize(serialize$1(any, options));
|
|
2415
|
-
function headingRank(node2) {
|
|
2416
|
-
const name = node2.type === "element" ? node2.tagName.toLowerCase() : "";
|
|
2417
|
-
const code2 = name.length === 2 && name.charCodeAt(0) === 104 ? name.charCodeAt(1) : 0;
|
|
2418
|
-
return code2 > 48 && code2 < 55 ? code2 - 48 : void 0;
|
|
2419
|
-
}
|
|
2420
|
-
const isElement = (
|
|
2421
|
-
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
2422
|
-
/**
|
|
2423
|
-
* @type {(
|
|
2424
|
-
* (<Condition extends TestFunction>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
2425
|
-
* (<Condition extends string>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
2426
|
-
* ((element?: null | undefined) => false) &
|
|
2427
|
-
* ((element: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
2428
|
-
* ((element: unknown, test?: Test, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => boolean)
|
|
2429
|
-
* )}
|
|
2430
|
-
*/
|
|
2431
|
-
/**
|
|
2432
|
-
* @param {unknown} [element]
|
|
2433
|
-
* @param {Test | undefined} [test]
|
|
2434
|
-
* @param {number | null | undefined} [index]
|
|
2435
|
-
* @param {Parents | null | undefined} [parent]
|
|
2436
|
-
* @param {unknown} [context]
|
|
2437
|
-
* @returns {boolean}
|
|
2438
|
-
*/
|
|
2439
|
-
// eslint-disable-next-line max-params
|
|
2440
|
-
function(element2, test, index2, parent, context) {
|
|
2441
|
-
const check = convertElement(test);
|
|
2442
|
-
return looksLikeAnElement(element2) ? check.call(context, element2, index2, parent) : false;
|
|
2443
|
-
}
|
|
2444
|
-
);
|
|
2445
|
-
const convertElement = (
|
|
2446
|
-
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
2447
|
-
/**
|
|
2448
|
-
* @type {(
|
|
2449
|
-
* (<Condition extends TestFunction>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
2450
|
-
* (<Condition extends string>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
2451
|
-
* ((test?: null | undefined) => (element?: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
2452
|
-
* ((test?: Test) => Check)
|
|
2453
|
-
* )}
|
|
2454
|
-
*/
|
|
2455
|
-
/**
|
|
2456
|
-
* @param {Test | null | undefined} [test]
|
|
2457
|
-
* @returns {Check}
|
|
2458
|
-
*/
|
|
2459
|
-
function(test) {
|
|
2460
|
-
if (test === null || test === void 0) {
|
|
2461
|
-
return element$4;
|
|
2462
|
-
}
|
|
2463
|
-
if (typeof test === "string") {
|
|
2464
|
-
return tagNameFactory(test);
|
|
2465
|
-
}
|
|
2466
|
-
if (typeof test === "object") {
|
|
2467
|
-
return anyFactory$1(test);
|
|
2468
|
-
}
|
|
2469
|
-
if (typeof test === "function") {
|
|
2470
|
-
return castFactory$1(test);
|
|
2471
|
-
}
|
|
2472
|
-
throw new Error("Expected function, string, or array as `test`");
|
|
2473
|
-
}
|
|
2474
|
-
);
|
|
2475
|
-
function anyFactory$1(tests) {
|
|
2476
|
-
const checks2 = [];
|
|
2477
|
-
let index2 = -1;
|
|
2478
|
-
while (++index2 < tests.length) {
|
|
2479
|
-
checks2[index2] = convertElement(tests[index2]);
|
|
2480
|
-
}
|
|
2481
|
-
return castFactory$1(any);
|
|
2482
|
-
function any(...parameters) {
|
|
2483
|
-
let index3 = -1;
|
|
2484
|
-
while (++index3 < checks2.length) {
|
|
2485
|
-
if (checks2[index3].apply(this, parameters)) return true;
|
|
2486
|
-
}
|
|
2487
|
-
return false;
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
function tagNameFactory(check) {
|
|
2491
|
-
return castFactory$1(tagName);
|
|
2492
|
-
function tagName(element2) {
|
|
2493
|
-
return element2.tagName === check;
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
|
-
function castFactory$1(testFunction) {
|
|
2497
|
-
return check;
|
|
2498
|
-
function check(value, index2, parent) {
|
|
2499
|
-
return Boolean(
|
|
2500
|
-
looksLikeAnElement(value) && testFunction.call(
|
|
2501
|
-
this,
|
|
2502
|
-
value,
|
|
2503
|
-
typeof index2 === "number" ? index2 : void 0,
|
|
2504
|
-
parent || void 0
|
|
2505
|
-
)
|
|
2506
|
-
);
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
function element$4(element2) {
|
|
2510
|
-
return Boolean(
|
|
2511
|
-
element2 && typeof element2 === "object" && "type" in element2 && element2.type === "element" && "tagName" in element2 && typeof element2.tagName === "string"
|
|
2512
|
-
);
|
|
2513
|
-
}
|
|
2514
|
-
function looksLikeAnElement(value) {
|
|
2515
|
-
return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
|
|
2516
|
-
}
|
|
2517
|
-
const convert = (
|
|
2518
|
-
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
2519
|
-
/**
|
|
2520
|
-
* @type {(
|
|
2521
|
-
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
|
|
2522
|
-
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
|
|
2523
|
-
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
2524
|
-
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
2525
|
-
* ((test?: Test) => Check)
|
|
2526
|
-
* )}
|
|
2527
|
-
*/
|
|
2528
|
-
/**
|
|
2529
|
-
* @param {Test} [test]
|
|
2530
|
-
* @returns {Check}
|
|
2531
|
-
*/
|
|
2532
|
-
function(test) {
|
|
2533
|
-
if (test === null || test === void 0) {
|
|
2534
|
-
return ok$1;
|
|
2535
|
-
}
|
|
2536
|
-
if (typeof test === "function") {
|
|
2537
|
-
return castFactory(test);
|
|
2538
|
-
}
|
|
2539
|
-
if (typeof test === "object") {
|
|
2540
|
-
return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
2541
|
-
}
|
|
2542
|
-
if (typeof test === "string") {
|
|
2543
|
-
return typeFactory(test);
|
|
2544
|
-
}
|
|
2545
|
-
throw new Error("Expected function, string, or object as test");
|
|
2546
|
-
}
|
|
2547
|
-
);
|
|
2548
|
-
function anyFactory(tests) {
|
|
2549
|
-
const checks2 = [];
|
|
2550
|
-
let index2 = -1;
|
|
2551
|
-
while (++index2 < tests.length) {
|
|
2552
|
-
checks2[index2] = convert(tests[index2]);
|
|
2553
|
-
}
|
|
2554
|
-
return castFactory(any);
|
|
2555
|
-
function any(...parameters) {
|
|
2556
|
-
let index3 = -1;
|
|
2557
|
-
while (++index3 < checks2.length) {
|
|
2558
|
-
if (checks2[index3].apply(this, parameters)) return true;
|
|
2559
|
-
}
|
|
2560
|
-
return false;
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
function propsFactory(check) {
|
|
2564
|
-
const checkAsRecord = (
|
|
2565
|
-
/** @type {Record<string, unknown>} */
|
|
2566
|
-
check
|
|
2567
|
-
);
|
|
2568
|
-
return castFactory(all2);
|
|
2569
|
-
function all2(node2) {
|
|
2570
|
-
const nodeAsRecord = (
|
|
2571
|
-
/** @type {Record<string, unknown>} */
|
|
2572
|
-
/** @type {unknown} */
|
|
2573
|
-
node2
|
|
2574
|
-
);
|
|
2575
|
-
let key2;
|
|
2576
|
-
for (key2 in check) {
|
|
2577
|
-
if (nodeAsRecord[key2] !== checkAsRecord[key2]) return false;
|
|
2578
|
-
}
|
|
2579
|
-
return true;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
function typeFactory(check) {
|
|
2583
|
-
return castFactory(type);
|
|
2584
|
-
function type(node2) {
|
|
2585
|
-
return node2 && node2.type === check;
|
|
2586
|
-
}
|
|
2587
|
-
}
|
|
2588
|
-
function castFactory(testFunction) {
|
|
2589
|
-
return check;
|
|
2590
|
-
function check(value, index2, parent) {
|
|
2591
|
-
return Boolean(
|
|
2592
|
-
looksLikeANode(value) && testFunction.call(
|
|
2593
|
-
this,
|
|
2594
|
-
value,
|
|
2595
|
-
typeof index2 === "number" ? index2 : void 0,
|
|
2596
|
-
parent || void 0
|
|
2597
|
-
)
|
|
2598
|
-
);
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
function ok$1() {
|
|
2602
|
-
return true;
|
|
2603
|
-
}
|
|
2604
|
-
function looksLikeANode(value) {
|
|
2605
|
-
return value !== null && typeof value === "object" && "type" in value;
|
|
2606
|
-
}
|
|
2607
|
-
function color(d) {
|
|
2608
|
-
return d;
|
|
2609
|
-
}
|
|
2610
|
-
const empty = [];
|
|
2611
|
-
const CONTINUE = true;
|
|
2612
|
-
const EXIT = false;
|
|
2613
|
-
const SKIP = "skip";
|
|
2614
|
-
function visitParents(tree, test, visitor, reverse) {
|
|
2615
|
-
let check;
|
|
2616
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
2617
|
-
reverse = visitor;
|
|
2618
|
-
visitor = test;
|
|
2619
|
-
} else {
|
|
2620
|
-
check = test;
|
|
2621
|
-
}
|
|
2622
|
-
const is = convert(check);
|
|
2623
|
-
const step = reverse ? -1 : 1;
|
|
2624
|
-
factory(tree, void 0, [])();
|
|
2625
|
-
function factory(node2, index2, parents) {
|
|
2626
|
-
const value = (
|
|
2627
|
-
/** @type {Record<string, unknown>} */
|
|
2628
|
-
node2 && typeof node2 === "object" ? node2 : {}
|
|
2629
|
-
);
|
|
2630
|
-
if (typeof value.type === "string") {
|
|
2631
|
-
const name = (
|
|
2632
|
-
// `hast`
|
|
2633
|
-
typeof value.tagName === "string" ? value.tagName : (
|
|
2634
|
-
// `xast`
|
|
2635
|
-
typeof value.name === "string" ? value.name : void 0
|
|
2636
|
-
)
|
|
2637
|
-
);
|
|
2638
|
-
Object.defineProperty(visit2, "name", {
|
|
2639
|
-
value: "node (" + color(node2.type + (name ? "<" + name + ">" : "")) + ")"
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
return visit2;
|
|
2643
|
-
function visit2() {
|
|
2644
|
-
let result = empty;
|
|
2645
|
-
let subresult;
|
|
2646
|
-
let offset;
|
|
2647
|
-
let grandparents;
|
|
2648
|
-
if (!test || is(node2, index2, parents[parents.length - 1] || void 0)) {
|
|
2649
|
-
result = toResult(visitor(node2, parents));
|
|
2650
|
-
if (result[0] === EXIT) {
|
|
2651
|
-
return result;
|
|
2652
|
-
}
|
|
2653
|
-
}
|
|
2654
|
-
if ("children" in node2 && node2.children) {
|
|
2655
|
-
const nodeAsParent = (
|
|
2656
|
-
/** @type {UnistParent} */
|
|
2657
|
-
node2
|
|
2658
|
-
);
|
|
2659
|
-
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
2660
|
-
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
2661
|
-
grandparents = parents.concat(nodeAsParent);
|
|
2662
|
-
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
2663
|
-
const child = nodeAsParent.children[offset];
|
|
2664
|
-
subresult = factory(child, offset, grandparents)();
|
|
2665
|
-
if (subresult[0] === EXIT) {
|
|
2666
|
-
return subresult;
|
|
2667
|
-
}
|
|
2668
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
return result;
|
|
2673
|
-
}
|
|
2674
|
-
}
|
|
2675
|
-
}
|
|
2676
|
-
function toResult(value) {
|
|
2677
|
-
if (Array.isArray(value)) {
|
|
2678
|
-
return value;
|
|
2679
|
-
}
|
|
2680
|
-
if (typeof value === "number") {
|
|
2681
|
-
return [CONTINUE, value];
|
|
2682
|
-
}
|
|
2683
|
-
return value === null || value === void 0 ? empty : [value];
|
|
2684
|
-
}
|
|
2685
|
-
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
2686
|
-
let reverse;
|
|
2687
|
-
let test;
|
|
2688
|
-
let visitor;
|
|
2689
|
-
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
2690
|
-
test = void 0;
|
|
2691
|
-
visitor = testOrVisitor;
|
|
2692
|
-
reverse = visitorOrReverse;
|
|
2693
|
-
} else {
|
|
2694
|
-
test = testOrVisitor;
|
|
2695
|
-
visitor = visitorOrReverse;
|
|
2696
|
-
reverse = maybeReverse;
|
|
2697
|
-
}
|
|
2698
|
-
visitParents(tree, test, overload, reverse);
|
|
2699
|
-
function overload(node2, parents) {
|
|
2700
|
-
const parent = parents[parents.length - 1];
|
|
2701
|
-
const index2 = parent ? parent.children.indexOf(node2) : void 0;
|
|
2702
|
-
return visitor(node2, index2, parent);
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
const contentDefaults = {
|
|
2706
|
-
type: "element",
|
|
2707
|
-
tagName: "span",
|
|
2708
|
-
properties: { className: ["icon", "icon-link"] },
|
|
2709
|
-
children: []
|
|
2710
|
-
};
|
|
2711
|
-
const emptyOptions$7 = {};
|
|
2712
|
-
function rehypeAutolinkHeadings(options) {
|
|
2713
|
-
const settings = options || emptyOptions$7;
|
|
2714
|
-
let properties = settings.properties;
|
|
2715
|
-
const headingOroperties = settings.headingProperties;
|
|
2716
|
-
const behavior = settings.behavior || "prepend";
|
|
2717
|
-
const content2 = settings.content;
|
|
2718
|
-
const group = settings.group;
|
|
2719
|
-
const is = convertElement(settings.test);
|
|
2720
|
-
let method;
|
|
2721
|
-
if (behavior === "after" || behavior === "before") {
|
|
2722
|
-
method = around;
|
|
2723
|
-
} else if (behavior === "wrap") {
|
|
2724
|
-
method = wrap2;
|
|
2725
|
-
} else {
|
|
2726
|
-
method = inject;
|
|
2727
|
-
if (!properties) {
|
|
2728
|
-
properties = { ariaHidden: "true", tabIndex: -1 };
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
return function(tree) {
|
|
2732
|
-
visit(tree, "element", function(node2, index2, parent) {
|
|
2733
|
-
if (headingRank(node2) && node2.properties.id && is(node2, index2, parent)) {
|
|
2734
|
-
Object.assign(node2.properties, toProperties(headingOroperties, node2));
|
|
2735
|
-
return method(node2, index2, parent);
|
|
2736
|
-
}
|
|
2737
|
-
});
|
|
2738
|
-
};
|
|
2739
|
-
function inject(node2) {
|
|
2740
|
-
const children = toChildren(content2 || contentDefaults, node2);
|
|
2741
|
-
node2.children[behavior === "prepend" ? "unshift" : "push"](
|
|
2742
|
-
create$4(node2, toProperties(properties, node2), children)
|
|
2743
|
-
);
|
|
2744
|
-
return [SKIP];
|
|
2745
|
-
}
|
|
2746
|
-
function around(node2, index2, parent) {
|
|
2747
|
-
if (typeof index2 !== "number" || !parent) return;
|
|
2748
|
-
const children = toChildren(content2 || contentDefaults, node2);
|
|
2749
|
-
const link2 = create$4(node2, toProperties(properties, node2), children);
|
|
2750
|
-
let nodes = behavior === "before" ? [link2, node2] : [node2, link2];
|
|
2751
|
-
if (group) {
|
|
2752
|
-
const grouping = toNode(group, node2);
|
|
2753
|
-
if (grouping && !Array.isArray(grouping) && grouping.type === "element") {
|
|
2754
|
-
grouping.children = nodes;
|
|
2755
|
-
nodes = [grouping];
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
parent.children.splice(index2, 1, ...nodes);
|
|
2759
|
-
return [SKIP, index2 + nodes.length];
|
|
2760
|
-
}
|
|
2761
|
-
function wrap2(node2) {
|
|
2762
|
-
let before = node2.children;
|
|
2763
|
-
let after = [];
|
|
2764
|
-
if (typeof content2 === "function") {
|
|
2765
|
-
before = [];
|
|
2766
|
-
after = content2(node2);
|
|
2767
|
-
} else if (content2) {
|
|
2768
|
-
after = clone(content2);
|
|
2769
|
-
}
|
|
2770
|
-
node2.children = [
|
|
2771
|
-
create$4(
|
|
2772
|
-
node2,
|
|
2773
|
-
toProperties(properties, node2),
|
|
2774
|
-
Array.isArray(after) ? [...before, ...after] : [...before, after]
|
|
2775
|
-
)
|
|
2776
|
-
];
|
|
2777
|
-
return [SKIP];
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
function clone(thing) {
|
|
2781
|
-
return (
|
|
2782
|
-
/** @type {Cloneable<T>} */
|
|
2783
|
-
structuredClone$1(thing)
|
|
2784
|
-
);
|
|
2785
|
-
}
|
|
2786
|
-
function create$4(node2, properties, children) {
|
|
2787
|
-
return {
|
|
2788
|
-
type: "element",
|
|
2789
|
-
tagName: "a",
|
|
2790
|
-
properties: { ...properties, href: "#" + node2.properties.id },
|
|
2791
|
-
children
|
|
2792
|
-
};
|
|
2793
|
-
}
|
|
2794
|
-
function toChildren(value, node2) {
|
|
2795
|
-
const result = toNode(value, node2);
|
|
2796
|
-
return Array.isArray(result) ? result : [result];
|
|
2797
|
-
}
|
|
2798
|
-
function toNode(value, node2) {
|
|
2799
|
-
if (typeof value === "function") return value(node2);
|
|
2800
|
-
return clone(value);
|
|
2801
|
-
}
|
|
2802
|
-
function toProperties(value, node2) {
|
|
2803
|
-
if (typeof value === "function") return value(node2);
|
|
2804
|
-
return value ? clone(value) : {};
|
|
2805
|
-
}
|
|
2806
|
-
function ok() {
|
|
2807
|
-
}
|
|
2808
|
-
const search = /[#.]/g;
|
|
2809
|
-
function parseSelector(selector, defaultTagName) {
|
|
2810
|
-
const value = selector || "";
|
|
2811
|
-
const props = {};
|
|
2812
|
-
let start = 0;
|
|
2813
|
-
let previous2;
|
|
2814
|
-
let tagName;
|
|
2815
|
-
while (start < value.length) {
|
|
2816
|
-
search.lastIndex = start;
|
|
2817
|
-
const match = search.exec(value);
|
|
2818
|
-
const subvalue = value.slice(start, match ? match.index : value.length);
|
|
2819
|
-
if (subvalue) {
|
|
2820
|
-
if (!previous2) {
|
|
2821
|
-
tagName = subvalue;
|
|
2822
|
-
} else if (previous2 === "#") {
|
|
2823
|
-
props.id = subvalue;
|
|
2824
|
-
} else if (Array.isArray(props.className)) {
|
|
2825
|
-
props.className.push(subvalue);
|
|
2826
|
-
} else {
|
|
2827
|
-
props.className = [subvalue];
|
|
2828
|
-
}
|
|
2829
|
-
start += subvalue.length;
|
|
2830
|
-
}
|
|
2831
|
-
if (match) {
|
|
2832
|
-
previous2 = match[0];
|
|
2833
|
-
start++;
|
|
2834
|
-
}
|
|
2835
|
-
}
|
|
2836
|
-
return {
|
|
2837
|
-
type: "element",
|
|
2838
|
-
// @ts-expect-error: tag name is parsed.
|
|
2839
|
-
tagName: tagName || defaultTagName || "div",
|
|
2840
|
-
properties: props,
|
|
2841
|
-
children: []
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
|
-
function createH(schema, defaultTagName, caseSensitive) {
|
|
2845
|
-
const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
|
|
2846
|
-
function h2(selector, properties, ...children) {
|
|
2847
|
-
let node2;
|
|
2848
|
-
if (selector === null || selector === void 0) {
|
|
2849
|
-
node2 = { type: "root", children: [] };
|
|
2850
|
-
const child = (
|
|
2851
|
-
/** @type {Child} */
|
|
2852
|
-
properties
|
|
2853
|
-
);
|
|
2854
|
-
children.unshift(child);
|
|
2855
|
-
} else {
|
|
2856
|
-
node2 = parseSelector(selector, defaultTagName);
|
|
2857
|
-
const lower = node2.tagName.toLowerCase();
|
|
2858
|
-
const adjusted = adjust ? adjust.get(lower) : void 0;
|
|
2859
|
-
node2.tagName = adjusted || lower;
|
|
2860
|
-
if (isChild(properties)) {
|
|
2861
|
-
children.unshift(properties);
|
|
2862
|
-
} else {
|
|
2863
|
-
for (const [key2, value] of Object.entries(properties)) {
|
|
2864
|
-
addProperty(schema, node2.properties, key2, value);
|
|
2303
|
+
}
|
|
2304
|
+
function createH(schema, defaultTagName, caseSensitive) {
|
|
2305
|
+
const adjust = caseSensitive ? createAdjustMap(caseSensitive) : void 0;
|
|
2306
|
+
function h2(selector, properties, ...children) {
|
|
2307
|
+
let node2;
|
|
2308
|
+
if (selector === null || selector === void 0) {
|
|
2309
|
+
node2 = { type: "root", children: [] };
|
|
2310
|
+
const child = (
|
|
2311
|
+
/** @type {Child} */
|
|
2312
|
+
properties
|
|
2313
|
+
);
|
|
2314
|
+
children.unshift(child);
|
|
2315
|
+
} else {
|
|
2316
|
+
node2 = parseSelector(selector, defaultTagName);
|
|
2317
|
+
const lower = node2.tagName.toLowerCase();
|
|
2318
|
+
const adjusted = adjust ? adjust.get(lower) : void 0;
|
|
2319
|
+
node2.tagName = adjusted || lower;
|
|
2320
|
+
if (isChild(properties)) {
|
|
2321
|
+
children.unshift(properties);
|
|
2322
|
+
} else {
|
|
2323
|
+
for (const [key2, value] of Object.entries(properties)) {
|
|
2324
|
+
addProperty(schema, node2.properties, key2, value);
|
|
2865
2325
|
}
|
|
2866
2326
|
}
|
|
2867
2327
|
}
|
|
@@ -3088,7 +2548,7 @@ const webNamespaces = {
|
|
|
3088
2548
|
xml: "http://www.w3.org/XML/1998/namespace",
|
|
3089
2549
|
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
3090
2550
|
};
|
|
3091
|
-
const own$
|
|
2551
|
+
const own$6 = {}.hasOwnProperty;
|
|
3092
2552
|
const proto = Object.prototype;
|
|
3093
2553
|
function fromParse5(tree, options) {
|
|
3094
2554
|
const settings = options || {};
|
|
@@ -3159,7 +2619,7 @@ function one$4(state, node2) {
|
|
|
3159
2619
|
/** @type {DefaultTreeAdapterMap['element']} */
|
|
3160
2620
|
node2
|
|
3161
2621
|
);
|
|
3162
|
-
result = element$
|
|
2622
|
+
result = element$4(state, reference);
|
|
3163
2623
|
return result;
|
|
3164
2624
|
}
|
|
3165
2625
|
}
|
|
@@ -3176,7 +2636,7 @@ function all$7(state, nodes) {
|
|
|
3176
2636
|
}
|
|
3177
2637
|
return results;
|
|
3178
2638
|
}
|
|
3179
|
-
function element$
|
|
2639
|
+
function element$4(state, node2) {
|
|
3180
2640
|
const schema = state.schema;
|
|
3181
2641
|
state.schema = node2.namespaceURI === webNamespaces.svg ? svg$2 : html$5;
|
|
3182
2642
|
let index2 = -1;
|
|
@@ -3184,7 +2644,7 @@ function element$3(state, node2) {
|
|
|
3184
2644
|
while (++index2 < node2.attrs.length) {
|
|
3185
2645
|
const attribute = node2.attrs[index2];
|
|
3186
2646
|
const name = (attribute.prefix ? attribute.prefix + ":" : "") + attribute.name;
|
|
3187
|
-
if (!own$
|
|
2647
|
+
if (!own$6.call(proto, name)) {
|
|
3188
2648
|
properties[name] = attribute.value;
|
|
3189
2649
|
}
|
|
3190
2650
|
}
|
|
@@ -3232,14 +2692,14 @@ function createLocation(state, node2, location2) {
|
|
|
3232
2692
|
let key2;
|
|
3233
2693
|
if (location2.attrs) {
|
|
3234
2694
|
for (key2 in location2.attrs) {
|
|
3235
|
-
if (own$
|
|
2695
|
+
if (own$6.call(location2.attrs, key2)) {
|
|
3236
2696
|
properties[find$1(state.schema, key2).property] = position$2(
|
|
3237
2697
|
location2.attrs[key2]
|
|
3238
2698
|
);
|
|
3239
2699
|
}
|
|
3240
2700
|
}
|
|
3241
2701
|
}
|
|
3242
|
-
ok(location2.startTag);
|
|
2702
|
+
ok$1(location2.startTag);
|
|
3243
2703
|
const opening2 = position$2(location2.startTag);
|
|
3244
2704
|
const closing2 = location2.endTag ? position$2(location2.endTag) : void 0;
|
|
3245
2705
|
const data = { opening: opening2 };
|
|
@@ -12342,11 +11802,220 @@ function rehypeParse(options) {
|
|
|
12342
11802
|
message.name = file.path + ":" + message.name;
|
|
12343
11803
|
message.file = file.path;
|
|
12344
11804
|
}
|
|
12345
|
-
file.messages.push(message);
|
|
12346
|
-
} : void 0
|
|
12347
|
-
});
|
|
12348
|
-
}
|
|
12349
|
-
}
|
|
11805
|
+
file.messages.push(message);
|
|
11806
|
+
} : void 0
|
|
11807
|
+
});
|
|
11808
|
+
}
|
|
11809
|
+
}
|
|
11810
|
+
const VOID = -1;
|
|
11811
|
+
const PRIMITIVE = 0;
|
|
11812
|
+
const ARRAY = 1;
|
|
11813
|
+
const OBJECT = 2;
|
|
11814
|
+
const DATE = 3;
|
|
11815
|
+
const REGEXP = 4;
|
|
11816
|
+
const MAP = 5;
|
|
11817
|
+
const SET = 6;
|
|
11818
|
+
const ERROR = 7;
|
|
11819
|
+
const BIGINT = 8;
|
|
11820
|
+
const env = typeof self === "object" ? self : globalThis;
|
|
11821
|
+
const deserializer = ($2, _) => {
|
|
11822
|
+
const as = (out, index2) => {
|
|
11823
|
+
$2.set(index2, out);
|
|
11824
|
+
return out;
|
|
11825
|
+
};
|
|
11826
|
+
const unpair = (index2) => {
|
|
11827
|
+
if ($2.has(index2))
|
|
11828
|
+
return $2.get(index2);
|
|
11829
|
+
const [type, value] = _[index2];
|
|
11830
|
+
switch (type) {
|
|
11831
|
+
case PRIMITIVE:
|
|
11832
|
+
case VOID:
|
|
11833
|
+
return as(value, index2);
|
|
11834
|
+
case ARRAY: {
|
|
11835
|
+
const arr = as([], index2);
|
|
11836
|
+
for (const index3 of value)
|
|
11837
|
+
arr.push(unpair(index3));
|
|
11838
|
+
return arr;
|
|
11839
|
+
}
|
|
11840
|
+
case OBJECT: {
|
|
11841
|
+
const object = as({}, index2);
|
|
11842
|
+
for (const [key2, index3] of value)
|
|
11843
|
+
object[unpair(key2)] = unpair(index3);
|
|
11844
|
+
return object;
|
|
11845
|
+
}
|
|
11846
|
+
case DATE:
|
|
11847
|
+
return as(new Date(value), index2);
|
|
11848
|
+
case REGEXP: {
|
|
11849
|
+
const { source, flags } = value;
|
|
11850
|
+
return as(new RegExp(source, flags), index2);
|
|
11851
|
+
}
|
|
11852
|
+
case MAP: {
|
|
11853
|
+
const map2 = as(/* @__PURE__ */ new Map(), index2);
|
|
11854
|
+
for (const [key2, index3] of value)
|
|
11855
|
+
map2.set(unpair(key2), unpair(index3));
|
|
11856
|
+
return map2;
|
|
11857
|
+
}
|
|
11858
|
+
case SET: {
|
|
11859
|
+
const set = as(/* @__PURE__ */ new Set(), index2);
|
|
11860
|
+
for (const index3 of value)
|
|
11861
|
+
set.add(unpair(index3));
|
|
11862
|
+
return set;
|
|
11863
|
+
}
|
|
11864
|
+
case ERROR: {
|
|
11865
|
+
const { name, message } = value;
|
|
11866
|
+
return as(new env[name](message), index2);
|
|
11867
|
+
}
|
|
11868
|
+
case BIGINT:
|
|
11869
|
+
return as(BigInt(value), index2);
|
|
11870
|
+
case "BigInt":
|
|
11871
|
+
return as(Object(BigInt(value)), index2);
|
|
11872
|
+
case "ArrayBuffer":
|
|
11873
|
+
return as(new Uint8Array(value).buffer, value);
|
|
11874
|
+
case "DataView": {
|
|
11875
|
+
const { buffer } = new Uint8Array(value);
|
|
11876
|
+
return as(new DataView(buffer), value);
|
|
11877
|
+
}
|
|
11878
|
+
}
|
|
11879
|
+
return as(new env[type](value), index2);
|
|
11880
|
+
};
|
|
11881
|
+
return unpair;
|
|
11882
|
+
};
|
|
11883
|
+
const deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
|
|
11884
|
+
const EMPTY = "";
|
|
11885
|
+
const { toString: toString$2 } = {};
|
|
11886
|
+
const { keys } = Object;
|
|
11887
|
+
const typeOf = (value) => {
|
|
11888
|
+
const type = typeof value;
|
|
11889
|
+
if (type !== "object" || !value)
|
|
11890
|
+
return [PRIMITIVE, type];
|
|
11891
|
+
const asString = toString$2.call(value).slice(8, -1);
|
|
11892
|
+
switch (asString) {
|
|
11893
|
+
case "Array":
|
|
11894
|
+
return [ARRAY, EMPTY];
|
|
11895
|
+
case "Object":
|
|
11896
|
+
return [OBJECT, EMPTY];
|
|
11897
|
+
case "Date":
|
|
11898
|
+
return [DATE, EMPTY];
|
|
11899
|
+
case "RegExp":
|
|
11900
|
+
return [REGEXP, EMPTY];
|
|
11901
|
+
case "Map":
|
|
11902
|
+
return [MAP, EMPTY];
|
|
11903
|
+
case "Set":
|
|
11904
|
+
return [SET, EMPTY];
|
|
11905
|
+
case "DataView":
|
|
11906
|
+
return [ARRAY, asString];
|
|
11907
|
+
}
|
|
11908
|
+
if (asString.includes("Array"))
|
|
11909
|
+
return [ARRAY, asString];
|
|
11910
|
+
if (asString.includes("Error"))
|
|
11911
|
+
return [ERROR, asString];
|
|
11912
|
+
return [OBJECT, asString];
|
|
11913
|
+
};
|
|
11914
|
+
const shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol");
|
|
11915
|
+
const serializer = (strict, json, $2, _) => {
|
|
11916
|
+
const as = (out, value) => {
|
|
11917
|
+
const index2 = _.push(out) - 1;
|
|
11918
|
+
$2.set(value, index2);
|
|
11919
|
+
return index2;
|
|
11920
|
+
};
|
|
11921
|
+
const pair = (value) => {
|
|
11922
|
+
if ($2.has(value))
|
|
11923
|
+
return $2.get(value);
|
|
11924
|
+
let [TYPE, type] = typeOf(value);
|
|
11925
|
+
switch (TYPE) {
|
|
11926
|
+
case PRIMITIVE: {
|
|
11927
|
+
let entry = value;
|
|
11928
|
+
switch (type) {
|
|
11929
|
+
case "bigint":
|
|
11930
|
+
TYPE = BIGINT;
|
|
11931
|
+
entry = value.toString();
|
|
11932
|
+
break;
|
|
11933
|
+
case "function":
|
|
11934
|
+
case "symbol":
|
|
11935
|
+
if (strict)
|
|
11936
|
+
throw new TypeError("unable to serialize " + type);
|
|
11937
|
+
entry = null;
|
|
11938
|
+
break;
|
|
11939
|
+
case "undefined":
|
|
11940
|
+
return as([VOID], value);
|
|
11941
|
+
}
|
|
11942
|
+
return as([TYPE, entry], value);
|
|
11943
|
+
}
|
|
11944
|
+
case ARRAY: {
|
|
11945
|
+
if (type) {
|
|
11946
|
+
let spread = value;
|
|
11947
|
+
if (type === "DataView") {
|
|
11948
|
+
spread = new Uint8Array(value.buffer);
|
|
11949
|
+
} else if (type === "ArrayBuffer") {
|
|
11950
|
+
spread = new Uint8Array(value);
|
|
11951
|
+
}
|
|
11952
|
+
return as([type, [...spread]], value);
|
|
11953
|
+
}
|
|
11954
|
+
const arr = [];
|
|
11955
|
+
const index2 = as([TYPE, arr], value);
|
|
11956
|
+
for (const entry of value)
|
|
11957
|
+
arr.push(pair(entry));
|
|
11958
|
+
return index2;
|
|
11959
|
+
}
|
|
11960
|
+
case OBJECT: {
|
|
11961
|
+
if (type) {
|
|
11962
|
+
switch (type) {
|
|
11963
|
+
case "BigInt":
|
|
11964
|
+
return as([type, value.toString()], value);
|
|
11965
|
+
case "Boolean":
|
|
11966
|
+
case "Number":
|
|
11967
|
+
case "String":
|
|
11968
|
+
return as([type, value.valueOf()], value);
|
|
11969
|
+
}
|
|
11970
|
+
}
|
|
11971
|
+
if (json && "toJSON" in value)
|
|
11972
|
+
return pair(value.toJSON());
|
|
11973
|
+
const entries = [];
|
|
11974
|
+
const index2 = as([TYPE, entries], value);
|
|
11975
|
+
for (const key2 of keys(value)) {
|
|
11976
|
+
if (strict || !shouldSkip(typeOf(value[key2])))
|
|
11977
|
+
entries.push([pair(key2), pair(value[key2])]);
|
|
11978
|
+
}
|
|
11979
|
+
return index2;
|
|
11980
|
+
}
|
|
11981
|
+
case DATE:
|
|
11982
|
+
return as([TYPE, value.toISOString()], value);
|
|
11983
|
+
case REGEXP: {
|
|
11984
|
+
const { source, flags } = value;
|
|
11985
|
+
return as([TYPE, { source, flags }], value);
|
|
11986
|
+
}
|
|
11987
|
+
case MAP: {
|
|
11988
|
+
const entries = [];
|
|
11989
|
+
const index2 = as([TYPE, entries], value);
|
|
11990
|
+
for (const [key2, entry] of value) {
|
|
11991
|
+
if (strict || !(shouldSkip(typeOf(key2)) || shouldSkip(typeOf(entry))))
|
|
11992
|
+
entries.push([pair(key2), pair(entry)]);
|
|
11993
|
+
}
|
|
11994
|
+
return index2;
|
|
11995
|
+
}
|
|
11996
|
+
case SET: {
|
|
11997
|
+
const entries = [];
|
|
11998
|
+
const index2 = as([TYPE, entries], value);
|
|
11999
|
+
for (const entry of value) {
|
|
12000
|
+
if (strict || !shouldSkip(typeOf(entry)))
|
|
12001
|
+
entries.push(pair(entry));
|
|
12002
|
+
}
|
|
12003
|
+
return index2;
|
|
12004
|
+
}
|
|
12005
|
+
}
|
|
12006
|
+
const { message } = value;
|
|
12007
|
+
return as([TYPE, { name: type, message }], value);
|
|
12008
|
+
};
|
|
12009
|
+
return pair;
|
|
12010
|
+
};
|
|
12011
|
+
const serialize$1 = (value, { json, lossy } = {}) => {
|
|
12012
|
+
const _ = [];
|
|
12013
|
+
return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
|
|
12014
|
+
};
|
|
12015
|
+
const structuredClone$1 = typeof structuredClone === "function" ? (
|
|
12016
|
+
/* c8 ignore start */
|
|
12017
|
+
(any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize$1(any, options)) : structuredClone(any)
|
|
12018
|
+
) : (any, options) => deserialize(serialize$1(any, options));
|
|
12350
12019
|
class Schema2 {
|
|
12351
12020
|
/**
|
|
12352
12021
|
* @constructor
|
|
@@ -12447,13 +12116,13 @@ function mark(values, key2, value) {
|
|
|
12447
12116
|
values[key2] = value;
|
|
12448
12117
|
}
|
|
12449
12118
|
}
|
|
12450
|
-
const own$
|
|
12119
|
+
const own$5 = {}.hasOwnProperty;
|
|
12451
12120
|
function create$3(definition2) {
|
|
12452
12121
|
const property = {};
|
|
12453
12122
|
const normal = {};
|
|
12454
12123
|
let prop;
|
|
12455
12124
|
for (prop in definition2.properties) {
|
|
12456
|
-
if (own$
|
|
12125
|
+
if (own$5.call(definition2.properties, prop)) {
|
|
12457
12126
|
const value = definition2.properties[prop];
|
|
12458
12127
|
const info = new DefinedInfo2(
|
|
12459
12128
|
prop,
|
|
@@ -13520,8 +13189,8 @@ function camelcase($0) {
|
|
|
13520
13189
|
const html$1 = merge([xml, xlink, xmlns, aria, html$2], "html");
|
|
13521
13190
|
const svg = merge([xml, xlink, xmlns, aria, svg$1], "svg");
|
|
13522
13191
|
const emptyOptions$5 = {};
|
|
13523
|
-
const own$
|
|
13524
|
-
const one$3 = zwitch("type", { handlers: { root: root$3, element: element$
|
|
13192
|
+
const own$4 = {}.hasOwnProperty;
|
|
13193
|
+
const one$3 = zwitch("type", { handlers: { root: root$3, element: element$3, text: text$4, comment: comment$2, doctype: doctype$1 } });
|
|
13525
13194
|
function toParse5(tree, options) {
|
|
13526
13195
|
const settings = options || emptyOptions$5;
|
|
13527
13196
|
const space = settings.space;
|
|
@@ -13573,7 +13242,7 @@ function comment$2(node2) {
|
|
|
13573
13242
|
patch$1(node2, result);
|
|
13574
13243
|
return result;
|
|
13575
13244
|
}
|
|
13576
|
-
function element$
|
|
13245
|
+
function element$3(node2, schema) {
|
|
13577
13246
|
const parentSchema = schema;
|
|
13578
13247
|
let currentSchema = parentSchema;
|
|
13579
13248
|
if (node2.type === "element" && node2.tagName.toLowerCase() === "svg" && parentSchema.space === "html") {
|
|
@@ -13583,106 +13252,294 @@ function element$2(node2, schema) {
|
|
|
13583
13252
|
let prop;
|
|
13584
13253
|
if (node2.properties) {
|
|
13585
13254
|
for (prop in node2.properties) {
|
|
13586
|
-
if (prop !== "children" && own$
|
|
13255
|
+
if (prop !== "children" && own$4.call(node2.properties, prop)) {
|
|
13587
13256
|
const result2 = createProperty(
|
|
13588
13257
|
currentSchema,
|
|
13589
13258
|
prop,
|
|
13590
13259
|
node2.properties[prop]
|
|
13591
13260
|
);
|
|
13592
|
-
if (result2) {
|
|
13593
|
-
attrs.push(result2);
|
|
13261
|
+
if (result2) {
|
|
13262
|
+
attrs.push(result2);
|
|
13263
|
+
}
|
|
13264
|
+
}
|
|
13265
|
+
}
|
|
13266
|
+
}
|
|
13267
|
+
const space = currentSchema.space;
|
|
13268
|
+
const result = {
|
|
13269
|
+
nodeName: node2.tagName,
|
|
13270
|
+
tagName: node2.tagName,
|
|
13271
|
+
attrs,
|
|
13272
|
+
// @ts-expect-error: `parse5` types are wrong.
|
|
13273
|
+
namespaceURI: webNamespaces[space],
|
|
13274
|
+
childNodes: [],
|
|
13275
|
+
parentNode: null
|
|
13276
|
+
};
|
|
13277
|
+
result.childNodes = all$6(node2.children, result, currentSchema);
|
|
13278
|
+
patch$1(node2, result);
|
|
13279
|
+
if (node2.tagName === "template" && node2.content) {
|
|
13280
|
+
result.content = fragment(node2.content, currentSchema);
|
|
13281
|
+
}
|
|
13282
|
+
return result;
|
|
13283
|
+
}
|
|
13284
|
+
function createProperty(schema, prop, value) {
|
|
13285
|
+
const info = find(schema, prop);
|
|
13286
|
+
if (value === false || value === null || value === void 0 || typeof value === "number" && Number.isNaN(value) || !value && info.boolean) {
|
|
13287
|
+
return;
|
|
13288
|
+
}
|
|
13289
|
+
if (Array.isArray(value)) {
|
|
13290
|
+
value = info.commaSeparated ? stringify$1(value) : stringify(value);
|
|
13291
|
+
}
|
|
13292
|
+
const attribute = {
|
|
13293
|
+
name: info.attribute,
|
|
13294
|
+
value: value === true ? "" : String(value)
|
|
13295
|
+
};
|
|
13296
|
+
if (info.space && info.space !== "html" && info.space !== "svg") {
|
|
13297
|
+
const index2 = attribute.name.indexOf(":");
|
|
13298
|
+
if (index2 < 0) {
|
|
13299
|
+
attribute.prefix = "";
|
|
13300
|
+
} else {
|
|
13301
|
+
attribute.name = attribute.name.slice(index2 + 1);
|
|
13302
|
+
attribute.prefix = info.attribute.slice(0, index2);
|
|
13303
|
+
}
|
|
13304
|
+
attribute.namespace = webNamespaces[info.space];
|
|
13305
|
+
}
|
|
13306
|
+
return attribute;
|
|
13307
|
+
}
|
|
13308
|
+
function all$6(children, parentNode, schema) {
|
|
13309
|
+
let index2 = -1;
|
|
13310
|
+
const results = [];
|
|
13311
|
+
if (children) {
|
|
13312
|
+
while (++index2 < children.length) {
|
|
13313
|
+
const child = one$3(children[index2], schema);
|
|
13314
|
+
child.parentNode = parentNode;
|
|
13315
|
+
results.push(child);
|
|
13316
|
+
}
|
|
13317
|
+
}
|
|
13318
|
+
return results;
|
|
13319
|
+
}
|
|
13320
|
+
function patch$1(from, to) {
|
|
13321
|
+
const position2 = from.position;
|
|
13322
|
+
if (position2 && position2.start && position2.end) {
|
|
13323
|
+
ok$1(typeof position2.start.offset === "number");
|
|
13324
|
+
ok$1(typeof position2.end.offset === "number");
|
|
13325
|
+
to.sourceCodeLocation = {
|
|
13326
|
+
startLine: position2.start.line,
|
|
13327
|
+
startCol: position2.start.column,
|
|
13328
|
+
startOffset: position2.start.offset,
|
|
13329
|
+
endLine: position2.end.line,
|
|
13330
|
+
endCol: position2.end.column,
|
|
13331
|
+
endOffset: position2.end.offset
|
|
13332
|
+
};
|
|
13333
|
+
}
|
|
13334
|
+
}
|
|
13335
|
+
const pointEnd = point("end");
|
|
13336
|
+
const pointStart = point("start");
|
|
13337
|
+
function point(type) {
|
|
13338
|
+
return point2;
|
|
13339
|
+
function point2(node2) {
|
|
13340
|
+
const point3 = node2 && node2.position && node2.position[type] || {};
|
|
13341
|
+
if (typeof point3.line === "number" && point3.line > 0 && typeof point3.column === "number" && point3.column > 0) {
|
|
13342
|
+
return {
|
|
13343
|
+
line: point3.line,
|
|
13344
|
+
column: point3.column,
|
|
13345
|
+
offset: typeof point3.offset === "number" && point3.offset > -1 ? point3.offset : void 0
|
|
13346
|
+
};
|
|
13347
|
+
}
|
|
13348
|
+
}
|
|
13349
|
+
}
|
|
13350
|
+
function position(node2) {
|
|
13351
|
+
const start = pointStart(node2);
|
|
13352
|
+
const end = pointEnd(node2);
|
|
13353
|
+
if (start && end) {
|
|
13354
|
+
return { start, end };
|
|
13355
|
+
}
|
|
13356
|
+
}
|
|
13357
|
+
const convert = (
|
|
13358
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
13359
|
+
/**
|
|
13360
|
+
* @type {(
|
|
13361
|
+
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
|
|
13362
|
+
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
|
|
13363
|
+
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
|
|
13364
|
+
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
|
|
13365
|
+
* ((test?: Test) => Check)
|
|
13366
|
+
* )}
|
|
13367
|
+
*/
|
|
13368
|
+
/**
|
|
13369
|
+
* @param {Test} [test]
|
|
13370
|
+
* @returns {Check}
|
|
13371
|
+
*/
|
|
13372
|
+
function(test) {
|
|
13373
|
+
if (test === null || test === void 0) {
|
|
13374
|
+
return ok;
|
|
13375
|
+
}
|
|
13376
|
+
if (typeof test === "function") {
|
|
13377
|
+
return castFactory$1(test);
|
|
13378
|
+
}
|
|
13379
|
+
if (typeof test === "object") {
|
|
13380
|
+
return Array.isArray(test) ? anyFactory$1(test) : propsFactory(test);
|
|
13381
|
+
}
|
|
13382
|
+
if (typeof test === "string") {
|
|
13383
|
+
return typeFactory(test);
|
|
13384
|
+
}
|
|
13385
|
+
throw new Error("Expected function, string, or object as test");
|
|
13386
|
+
}
|
|
13387
|
+
);
|
|
13388
|
+
function anyFactory$1(tests) {
|
|
13389
|
+
const checks2 = [];
|
|
13390
|
+
let index2 = -1;
|
|
13391
|
+
while (++index2 < tests.length) {
|
|
13392
|
+
checks2[index2] = convert(tests[index2]);
|
|
13393
|
+
}
|
|
13394
|
+
return castFactory$1(any);
|
|
13395
|
+
function any(...parameters) {
|
|
13396
|
+
let index3 = -1;
|
|
13397
|
+
while (++index3 < checks2.length) {
|
|
13398
|
+
if (checks2[index3].apply(this, parameters)) return true;
|
|
13399
|
+
}
|
|
13400
|
+
return false;
|
|
13401
|
+
}
|
|
13402
|
+
}
|
|
13403
|
+
function propsFactory(check) {
|
|
13404
|
+
const checkAsRecord = (
|
|
13405
|
+
/** @type {Record<string, unknown>} */
|
|
13406
|
+
check
|
|
13407
|
+
);
|
|
13408
|
+
return castFactory$1(all2);
|
|
13409
|
+
function all2(node2) {
|
|
13410
|
+
const nodeAsRecord = (
|
|
13411
|
+
/** @type {Record<string, unknown>} */
|
|
13412
|
+
/** @type {unknown} */
|
|
13413
|
+
node2
|
|
13414
|
+
);
|
|
13415
|
+
let key2;
|
|
13416
|
+
for (key2 in check) {
|
|
13417
|
+
if (nodeAsRecord[key2] !== checkAsRecord[key2]) return false;
|
|
13418
|
+
}
|
|
13419
|
+
return true;
|
|
13420
|
+
}
|
|
13421
|
+
}
|
|
13422
|
+
function typeFactory(check) {
|
|
13423
|
+
return castFactory$1(type);
|
|
13424
|
+
function type(node2) {
|
|
13425
|
+
return node2 && node2.type === check;
|
|
13426
|
+
}
|
|
13427
|
+
}
|
|
13428
|
+
function castFactory$1(testFunction) {
|
|
13429
|
+
return check;
|
|
13430
|
+
function check(value, index2, parent) {
|
|
13431
|
+
return Boolean(
|
|
13432
|
+
looksLikeANode(value) && testFunction.call(
|
|
13433
|
+
this,
|
|
13434
|
+
value,
|
|
13435
|
+
typeof index2 === "number" ? index2 : void 0,
|
|
13436
|
+
parent || void 0
|
|
13437
|
+
)
|
|
13438
|
+
);
|
|
13439
|
+
}
|
|
13440
|
+
}
|
|
13441
|
+
function ok() {
|
|
13442
|
+
return true;
|
|
13443
|
+
}
|
|
13444
|
+
function looksLikeANode(value) {
|
|
13445
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
13446
|
+
}
|
|
13447
|
+
function color(d) {
|
|
13448
|
+
return d;
|
|
13449
|
+
}
|
|
13450
|
+
const empty = [];
|
|
13451
|
+
const CONTINUE = true;
|
|
13452
|
+
const EXIT = false;
|
|
13453
|
+
const SKIP = "skip";
|
|
13454
|
+
function visitParents(tree, test, visitor, reverse) {
|
|
13455
|
+
let check;
|
|
13456
|
+
if (typeof test === "function" && typeof visitor !== "function") {
|
|
13457
|
+
reverse = visitor;
|
|
13458
|
+
visitor = test;
|
|
13459
|
+
} else {
|
|
13460
|
+
check = test;
|
|
13461
|
+
}
|
|
13462
|
+
const is = convert(check);
|
|
13463
|
+
const step = reverse ? -1 : 1;
|
|
13464
|
+
factory(tree, void 0, [])();
|
|
13465
|
+
function factory(node2, index2, parents) {
|
|
13466
|
+
const value = (
|
|
13467
|
+
/** @type {Record<string, unknown>} */
|
|
13468
|
+
node2 && typeof node2 === "object" ? node2 : {}
|
|
13469
|
+
);
|
|
13470
|
+
if (typeof value.type === "string") {
|
|
13471
|
+
const name = (
|
|
13472
|
+
// `hast`
|
|
13473
|
+
typeof value.tagName === "string" ? value.tagName : (
|
|
13474
|
+
// `xast`
|
|
13475
|
+
typeof value.name === "string" ? value.name : void 0
|
|
13476
|
+
)
|
|
13477
|
+
);
|
|
13478
|
+
Object.defineProperty(visit2, "name", {
|
|
13479
|
+
value: "node (" + color(node2.type + (name ? "<" + name + ">" : "")) + ")"
|
|
13480
|
+
});
|
|
13481
|
+
}
|
|
13482
|
+
return visit2;
|
|
13483
|
+
function visit2() {
|
|
13484
|
+
let result = empty;
|
|
13485
|
+
let subresult;
|
|
13486
|
+
let offset;
|
|
13487
|
+
let grandparents;
|
|
13488
|
+
if (!test || is(node2, index2, parents[parents.length - 1] || void 0)) {
|
|
13489
|
+
result = toResult(visitor(node2, parents));
|
|
13490
|
+
if (result[0] === EXIT) {
|
|
13491
|
+
return result;
|
|
13492
|
+
}
|
|
13493
|
+
}
|
|
13494
|
+
if ("children" in node2 && node2.children) {
|
|
13495
|
+
const nodeAsParent = (
|
|
13496
|
+
/** @type {UnistParent} */
|
|
13497
|
+
node2
|
|
13498
|
+
);
|
|
13499
|
+
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
13500
|
+
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
13501
|
+
grandparents = parents.concat(nodeAsParent);
|
|
13502
|
+
while (offset > -1 && offset < nodeAsParent.children.length) {
|
|
13503
|
+
const child = nodeAsParent.children[offset];
|
|
13504
|
+
subresult = factory(child, offset, grandparents)();
|
|
13505
|
+
if (subresult[0] === EXIT) {
|
|
13506
|
+
return subresult;
|
|
13507
|
+
}
|
|
13508
|
+
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
13509
|
+
}
|
|
13594
13510
|
}
|
|
13595
13511
|
}
|
|
13512
|
+
return result;
|
|
13596
13513
|
}
|
|
13597
13514
|
}
|
|
13598
|
-
const space = currentSchema.space;
|
|
13599
|
-
const result = {
|
|
13600
|
-
nodeName: node2.tagName,
|
|
13601
|
-
tagName: node2.tagName,
|
|
13602
|
-
attrs,
|
|
13603
|
-
// @ts-expect-error: `parse5` types are wrong.
|
|
13604
|
-
namespaceURI: webNamespaces[space],
|
|
13605
|
-
childNodes: [],
|
|
13606
|
-
parentNode: null
|
|
13607
|
-
};
|
|
13608
|
-
result.childNodes = all$6(node2.children, result, currentSchema);
|
|
13609
|
-
patch$1(node2, result);
|
|
13610
|
-
if (node2.tagName === "template" && node2.content) {
|
|
13611
|
-
result.content = fragment(node2.content, currentSchema);
|
|
13612
|
-
}
|
|
13613
|
-
return result;
|
|
13614
13515
|
}
|
|
13615
|
-
function
|
|
13616
|
-
const info = find(schema, prop);
|
|
13617
|
-
if (value === false || value === null || value === void 0 || typeof value === "number" && Number.isNaN(value) || !value && info.boolean) {
|
|
13618
|
-
return;
|
|
13619
|
-
}
|
|
13516
|
+
function toResult(value) {
|
|
13620
13517
|
if (Array.isArray(value)) {
|
|
13621
|
-
|
|
13622
|
-
}
|
|
13623
|
-
const attribute = {
|
|
13624
|
-
name: info.attribute,
|
|
13625
|
-
value: value === true ? "" : String(value)
|
|
13626
|
-
};
|
|
13627
|
-
if (info.space && info.space !== "html" && info.space !== "svg") {
|
|
13628
|
-
const index2 = attribute.name.indexOf(":");
|
|
13629
|
-
if (index2 < 0) {
|
|
13630
|
-
attribute.prefix = "";
|
|
13631
|
-
} else {
|
|
13632
|
-
attribute.name = attribute.name.slice(index2 + 1);
|
|
13633
|
-
attribute.prefix = info.attribute.slice(0, index2);
|
|
13634
|
-
}
|
|
13635
|
-
attribute.namespace = webNamespaces[info.space];
|
|
13636
|
-
}
|
|
13637
|
-
return attribute;
|
|
13638
|
-
}
|
|
13639
|
-
function all$6(children, parentNode, schema) {
|
|
13640
|
-
let index2 = -1;
|
|
13641
|
-
const results = [];
|
|
13642
|
-
if (children) {
|
|
13643
|
-
while (++index2 < children.length) {
|
|
13644
|
-
const child = one$3(children[index2], schema);
|
|
13645
|
-
child.parentNode = parentNode;
|
|
13646
|
-
results.push(child);
|
|
13647
|
-
}
|
|
13518
|
+
return value;
|
|
13648
13519
|
}
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
function patch$1(from, to) {
|
|
13652
|
-
const position2 = from.position;
|
|
13653
|
-
if (position2 && position2.start && position2.end) {
|
|
13654
|
-
ok(typeof position2.start.offset === "number");
|
|
13655
|
-
ok(typeof position2.end.offset === "number");
|
|
13656
|
-
to.sourceCodeLocation = {
|
|
13657
|
-
startLine: position2.start.line,
|
|
13658
|
-
startCol: position2.start.column,
|
|
13659
|
-
startOffset: position2.start.offset,
|
|
13660
|
-
endLine: position2.end.line,
|
|
13661
|
-
endCol: position2.end.column,
|
|
13662
|
-
endOffset: position2.end.offset
|
|
13663
|
-
};
|
|
13520
|
+
if (typeof value === "number") {
|
|
13521
|
+
return [CONTINUE, value];
|
|
13664
13522
|
}
|
|
13523
|
+
return value === null || value === void 0 ? empty : [value];
|
|
13665
13524
|
}
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
function
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
}
|
|
13525
|
+
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
13526
|
+
let reverse;
|
|
13527
|
+
let test;
|
|
13528
|
+
let visitor;
|
|
13529
|
+
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
|
|
13530
|
+
test = void 0;
|
|
13531
|
+
visitor = testOrVisitor;
|
|
13532
|
+
reverse = visitorOrReverse;
|
|
13533
|
+
} else {
|
|
13534
|
+
test = testOrVisitor;
|
|
13535
|
+
visitor = visitorOrReverse;
|
|
13536
|
+
reverse = maybeReverse;
|
|
13679
13537
|
}
|
|
13680
|
-
|
|
13681
|
-
function
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
return { start, end };
|
|
13538
|
+
visitParents(tree, test, overload, reverse);
|
|
13539
|
+
function overload(node2, parents) {
|
|
13540
|
+
const parent = parents[parents.length - 1];
|
|
13541
|
+
const index2 = parent ? parent.children.indexOf(node2) : void 0;
|
|
13542
|
+
return visitor(node2, index2, parent);
|
|
13686
13543
|
}
|
|
13687
13544
|
}
|
|
13688
13545
|
const gfmTagfilterExpression = /<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi;
|
|
@@ -13697,7 +13554,7 @@ const parseOptions = { sourceCodeLocationInfo: true, scriptingEnabled: false };
|
|
|
13697
13554
|
function raw(tree, options) {
|
|
13698
13555
|
const document2 = documentMode(tree);
|
|
13699
13556
|
const one2 = zwitch("type", {
|
|
13700
|
-
handlers: { root: root$2, element: element$
|
|
13557
|
+
handlers: { root: root$2, element: element$2, text: text$3, comment: comment$1, doctype, raw: handleRaw },
|
|
13701
13558
|
unknown: unknown$1
|
|
13702
13559
|
});
|
|
13703
13560
|
const state = {
|
|
@@ -13745,7 +13602,7 @@ function all$5(nodes, state) {
|
|
|
13745
13602
|
function root$2(node2, state) {
|
|
13746
13603
|
all$5(node2.children, state);
|
|
13747
13604
|
}
|
|
13748
|
-
function element$
|
|
13605
|
+
function element$2(node2, state) {
|
|
13749
13606
|
startTag(node2, state);
|
|
13750
13607
|
all$5(node2.children, state);
|
|
13751
13608
|
endTag(node2, state);
|
|
@@ -13778,15 +13635,15 @@ function doctype(node2, state) {
|
|
|
13778
13635
|
}
|
|
13779
13636
|
function stitch(node2, state) {
|
|
13780
13637
|
state.stitches = true;
|
|
13781
|
-
const
|
|
13782
|
-
if ("children" in node2 && "children" in
|
|
13638
|
+
const clone = cloneWithoutChildren$1(node2);
|
|
13639
|
+
if ("children" in node2 && "children" in clone) {
|
|
13783
13640
|
const fakeRoot = (
|
|
13784
13641
|
/** @type {Root} */
|
|
13785
13642
|
raw({ type: "root", children: node2.children }, state.options)
|
|
13786
13643
|
);
|
|
13787
|
-
|
|
13644
|
+
clone.children = fakeRoot.children;
|
|
13788
13645
|
}
|
|
13789
|
-
comment$1({ type: "comment", value: { stitch:
|
|
13646
|
+
comment$1({ type: "comment", value: { stitch: clone } }, state);
|
|
13790
13647
|
}
|
|
13791
13648
|
function comment$1(node2, state) {
|
|
13792
13649
|
const data = node2.value;
|
|
@@ -13903,72 +13760,169 @@ function startTag(node2, state) {
|
|
|
13903
13760
|
state.parser._processToken(state.parser.currentToken);
|
|
13904
13761
|
state.parser.tokenizer.lastStartTagName = tagName;
|
|
13905
13762
|
}
|
|
13906
|
-
function endTag(node2, state) {
|
|
13907
|
-
const tagName = node2.tagName.toLowerCase();
|
|
13908
|
-
if (!state.parser.tokenizer.inForeignNode && htmlVoidElements.includes(tagName)) {
|
|
13909
|
-
return;
|
|
13763
|
+
function endTag(node2, state) {
|
|
13764
|
+
const tagName = node2.tagName.toLowerCase();
|
|
13765
|
+
if (!state.parser.tokenizer.inForeignNode && htmlVoidElements.includes(tagName)) {
|
|
13766
|
+
return;
|
|
13767
|
+
}
|
|
13768
|
+
if (state.parser.tokenizer.state === TokenizerMode.PLAINTEXT) return;
|
|
13769
|
+
resetTokenizer(state, pointEnd(node2));
|
|
13770
|
+
const tag = {
|
|
13771
|
+
type: TokenType.END_TAG,
|
|
13772
|
+
tagName,
|
|
13773
|
+
tagID: getTagID(tagName),
|
|
13774
|
+
selfClosing: false,
|
|
13775
|
+
ackSelfClosing: false,
|
|
13776
|
+
attrs: [],
|
|
13777
|
+
location: createParse5Location(node2)
|
|
13778
|
+
};
|
|
13779
|
+
state.parser.currentToken = tag;
|
|
13780
|
+
state.parser._processToken(state.parser.currentToken);
|
|
13781
|
+
if (
|
|
13782
|
+
// Current element is closed.
|
|
13783
|
+
tagName === state.parser.tokenizer.lastStartTagName && // `<textarea>` and `<title>`
|
|
13784
|
+
(state.parser.tokenizer.state === TokenizerMode.RCDATA || // `<iframe>`, `<noembed>`, `<noframes>`, `<style>`, `<xmp>`
|
|
13785
|
+
state.parser.tokenizer.state === TokenizerMode.RAWTEXT || // `<script>`
|
|
13786
|
+
state.parser.tokenizer.state === TokenizerMode.SCRIPT_DATA)
|
|
13787
|
+
) {
|
|
13788
|
+
state.parser.tokenizer.state = TokenizerMode.DATA;
|
|
13789
|
+
}
|
|
13790
|
+
}
|
|
13791
|
+
function documentMode(node2) {
|
|
13792
|
+
const head2 = node2.type === "root" ? node2.children[0] : node2;
|
|
13793
|
+
return Boolean(
|
|
13794
|
+
head2 && (head2.type === "doctype" || head2.type === "element" && head2.tagName.toLowerCase() === "html")
|
|
13795
|
+
);
|
|
13796
|
+
}
|
|
13797
|
+
function createParse5Location(node2) {
|
|
13798
|
+
const start = pointStart(node2) || {
|
|
13799
|
+
line: void 0,
|
|
13800
|
+
column: void 0,
|
|
13801
|
+
offset: void 0
|
|
13802
|
+
};
|
|
13803
|
+
const end = pointEnd(node2) || {
|
|
13804
|
+
line: void 0,
|
|
13805
|
+
column: void 0,
|
|
13806
|
+
offset: void 0
|
|
13807
|
+
};
|
|
13808
|
+
const location2 = {
|
|
13809
|
+
startLine: start.line,
|
|
13810
|
+
startCol: start.column,
|
|
13811
|
+
startOffset: start.offset,
|
|
13812
|
+
endLine: end.line,
|
|
13813
|
+
endCol: end.column,
|
|
13814
|
+
endOffset: end.offset
|
|
13815
|
+
};
|
|
13816
|
+
return location2;
|
|
13817
|
+
}
|
|
13818
|
+
function cloneWithoutChildren$1(node2) {
|
|
13819
|
+
return "children" in node2 ? structuredClone$1({ ...node2, children: [] }) : structuredClone$1(node2);
|
|
13820
|
+
}
|
|
13821
|
+
function rehypeRaw(options) {
|
|
13822
|
+
return function(tree, file) {
|
|
13823
|
+
const result = (
|
|
13824
|
+
/** @type {Root} */
|
|
13825
|
+
raw(tree, { ...options, file })
|
|
13826
|
+
);
|
|
13827
|
+
return result;
|
|
13828
|
+
};
|
|
13829
|
+
}
|
|
13830
|
+
const isElement = (
|
|
13831
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
13832
|
+
/**
|
|
13833
|
+
* @type {(
|
|
13834
|
+
* (<Condition extends TestFunction>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
13835
|
+
* (<Condition extends string>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
13836
|
+
* ((element?: null | undefined) => false) &
|
|
13837
|
+
* ((element: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
13838
|
+
* ((element: unknown, test?: Test, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => boolean)
|
|
13839
|
+
* )}
|
|
13840
|
+
*/
|
|
13841
|
+
/**
|
|
13842
|
+
* @param {unknown} [element]
|
|
13843
|
+
* @param {Test | undefined} [test]
|
|
13844
|
+
* @param {number | null | undefined} [index]
|
|
13845
|
+
* @param {Parents | null | undefined} [parent]
|
|
13846
|
+
* @param {unknown} [context]
|
|
13847
|
+
* @returns {boolean}
|
|
13848
|
+
*/
|
|
13849
|
+
// eslint-disable-next-line max-params
|
|
13850
|
+
function(element2, test, index2, parent, context) {
|
|
13851
|
+
const check = convertElement(test);
|
|
13852
|
+
return looksLikeAnElement(element2) ? check.call(context, element2, index2, parent) : false;
|
|
13853
|
+
}
|
|
13854
|
+
);
|
|
13855
|
+
const convertElement = (
|
|
13856
|
+
// Note: overloads in JSDoc can’t yet use different `@template`s.
|
|
13857
|
+
/**
|
|
13858
|
+
* @type {(
|
|
13859
|
+
* (<Condition extends TestFunction>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
|
|
13860
|
+
* (<Condition extends string>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
|
|
13861
|
+
* ((test?: null | undefined) => (element?: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
|
|
13862
|
+
* ((test?: Test) => Check)
|
|
13863
|
+
* )}
|
|
13864
|
+
*/
|
|
13865
|
+
/**
|
|
13866
|
+
* @param {Test | null | undefined} [test]
|
|
13867
|
+
* @returns {Check}
|
|
13868
|
+
*/
|
|
13869
|
+
function(test) {
|
|
13870
|
+
if (test === null || test === void 0) {
|
|
13871
|
+
return element$1;
|
|
13872
|
+
}
|
|
13873
|
+
if (typeof test === "string") {
|
|
13874
|
+
return tagNameFactory(test);
|
|
13875
|
+
}
|
|
13876
|
+
if (typeof test === "object") {
|
|
13877
|
+
return anyFactory(test);
|
|
13878
|
+
}
|
|
13879
|
+
if (typeof test === "function") {
|
|
13880
|
+
return castFactory(test);
|
|
13881
|
+
}
|
|
13882
|
+
throw new Error("Expected function, string, or array as `test`");
|
|
13883
|
+
}
|
|
13884
|
+
);
|
|
13885
|
+
function anyFactory(tests) {
|
|
13886
|
+
const checks2 = [];
|
|
13887
|
+
let index2 = -1;
|
|
13888
|
+
while (++index2 < tests.length) {
|
|
13889
|
+
checks2[index2] = convertElement(tests[index2]);
|
|
13890
|
+
}
|
|
13891
|
+
return castFactory(any);
|
|
13892
|
+
function any(...parameters) {
|
|
13893
|
+
let index3 = -1;
|
|
13894
|
+
while (++index3 < checks2.length) {
|
|
13895
|
+
if (checks2[index3].apply(this, parameters)) return true;
|
|
13896
|
+
}
|
|
13897
|
+
return false;
|
|
13898
|
+
}
|
|
13899
|
+
}
|
|
13900
|
+
function tagNameFactory(check) {
|
|
13901
|
+
return castFactory(tagName);
|
|
13902
|
+
function tagName(element2) {
|
|
13903
|
+
return element2.tagName === check;
|
|
13910
13904
|
}
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13915
|
-
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
state.parser._processToken(state.parser.currentToken);
|
|
13924
|
-
if (
|
|
13925
|
-
// Current element is closed.
|
|
13926
|
-
tagName === state.parser.tokenizer.lastStartTagName && // `<textarea>` and `<title>`
|
|
13927
|
-
(state.parser.tokenizer.state === TokenizerMode.RCDATA || // `<iframe>`, `<noembed>`, `<noframes>`, `<style>`, `<xmp>`
|
|
13928
|
-
state.parser.tokenizer.state === TokenizerMode.RAWTEXT || // `<script>`
|
|
13929
|
-
state.parser.tokenizer.state === TokenizerMode.SCRIPT_DATA)
|
|
13930
|
-
) {
|
|
13931
|
-
state.parser.tokenizer.state = TokenizerMode.DATA;
|
|
13905
|
+
}
|
|
13906
|
+
function castFactory(testFunction) {
|
|
13907
|
+
return check;
|
|
13908
|
+
function check(value, index2, parent) {
|
|
13909
|
+
return Boolean(
|
|
13910
|
+
looksLikeAnElement(value) && testFunction.call(
|
|
13911
|
+
this,
|
|
13912
|
+
value,
|
|
13913
|
+
typeof index2 === "number" ? index2 : void 0,
|
|
13914
|
+
parent || void 0
|
|
13915
|
+
)
|
|
13916
|
+
);
|
|
13932
13917
|
}
|
|
13933
13918
|
}
|
|
13934
|
-
function
|
|
13935
|
-
const head2 = node2.type === "root" ? node2.children[0] : node2;
|
|
13919
|
+
function element$1(element2) {
|
|
13936
13920
|
return Boolean(
|
|
13937
|
-
|
|
13921
|
+
element2 && typeof element2 === "object" && "type" in element2 && element2.type === "element" && "tagName" in element2 && typeof element2.tagName === "string"
|
|
13938
13922
|
);
|
|
13939
13923
|
}
|
|
13940
|
-
function
|
|
13941
|
-
|
|
13942
|
-
line: void 0,
|
|
13943
|
-
column: void 0,
|
|
13944
|
-
offset: void 0
|
|
13945
|
-
};
|
|
13946
|
-
const end = pointEnd(node2) || {
|
|
13947
|
-
line: void 0,
|
|
13948
|
-
column: void 0,
|
|
13949
|
-
offset: void 0
|
|
13950
|
-
};
|
|
13951
|
-
const location2 = {
|
|
13952
|
-
startLine: start.line,
|
|
13953
|
-
startCol: start.column,
|
|
13954
|
-
startOffset: start.offset,
|
|
13955
|
-
endLine: end.line,
|
|
13956
|
-
endCol: end.column,
|
|
13957
|
-
endOffset: end.offset
|
|
13958
|
-
};
|
|
13959
|
-
return location2;
|
|
13960
|
-
}
|
|
13961
|
-
function cloneWithoutChildren$1(node2) {
|
|
13962
|
-
return "children" in node2 ? structuredClone$1({ ...node2, children: [] }) : structuredClone$1(node2);
|
|
13963
|
-
}
|
|
13964
|
-
function rehypeRaw(options) {
|
|
13965
|
-
return function(tree, file) {
|
|
13966
|
-
const result = (
|
|
13967
|
-
/** @type {Root} */
|
|
13968
|
-
raw(tree, { ...options, file })
|
|
13969
|
-
);
|
|
13970
|
-
return result;
|
|
13971
|
-
};
|
|
13924
|
+
function looksLikeAnElement(value) {
|
|
13925
|
+
return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
|
|
13972
13926
|
}
|
|
13973
13927
|
const embedded = convertElement(
|
|
13974
13928
|
/**
|
|
@@ -14994,9 +14948,9 @@ function input(state, node2) {
|
|
|
14994
14948
|
state.patch(node2, result);
|
|
14995
14949
|
return result;
|
|
14996
14950
|
}
|
|
14997
|
-
const own$
|
|
14951
|
+
const own$3 = {}.hasOwnProperty;
|
|
14998
14952
|
function hasProperty(node2, name) {
|
|
14999
|
-
const value = node2.type === "element" && own$
|
|
14953
|
+
const value = node2.type === "element" && own$3.call(node2.properties, name) && node2.properties[name];
|
|
15000
14954
|
return value !== null && value !== void 0 && value !== false;
|
|
15001
14955
|
}
|
|
15002
14956
|
const list$3 = /* @__PURE__ */ new Set(["pingback", "prefetch", "stylesheet"]);
|
|
@@ -15711,7 +15665,7 @@ function flow(state, node2) {
|
|
|
15711
15665
|
}
|
|
15712
15666
|
function ignore() {
|
|
15713
15667
|
}
|
|
15714
|
-
const own$
|
|
15668
|
+
const own$2 = {}.hasOwnProperty;
|
|
15715
15669
|
function createState(options) {
|
|
15716
15670
|
return {
|
|
15717
15671
|
all: all$1,
|
|
@@ -15753,10 +15707,10 @@ function one$1(node2, parent) {
|
|
|
15753
15707
|
if (node2.properties && node2.properties.dataMdast === "ignore") {
|
|
15754
15708
|
return;
|
|
15755
15709
|
}
|
|
15756
|
-
if (own$
|
|
15710
|
+
if (own$2.call(this.handlers, node2.tagName)) {
|
|
15757
15711
|
return this.handlers[node2.tagName](this, node2, parent) || void 0;
|
|
15758
15712
|
}
|
|
15759
|
-
} else if (own$
|
|
15713
|
+
} else if (own$2.call(this.nodeHandlers, node2.type)) {
|
|
15760
15714
|
return this.nodeHandlers[node2.type](this, node2, parent) || void 0;
|
|
15761
15715
|
}
|
|
15762
15716
|
if ("value" in node2 && typeof node2.value === "string") {
|
|
@@ -15892,54 +15846,10 @@ function rehypeRemark(destination, options) {
|
|
|
15892
15846
|
);
|
|
15893
15847
|
};
|
|
15894
15848
|
}
|
|
15895
|
-
|
|
15896
|
-
const
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
* Create a new slug class.
|
|
15900
|
-
*/
|
|
15901
|
-
constructor() {
|
|
15902
|
-
this.occurrences;
|
|
15903
|
-
this.reset();
|
|
15904
|
-
}
|
|
15905
|
-
/**
|
|
15906
|
-
* Generate a unique slug.
|
|
15907
|
-
*
|
|
15908
|
-
* Tracks previously generated slugs: repeated calls with the same value
|
|
15909
|
-
* will result in different slugs.
|
|
15910
|
-
* Use the `slug` function to get same slugs.
|
|
15911
|
-
*
|
|
15912
|
-
* @param {string} value
|
|
15913
|
-
* String of text to slugify
|
|
15914
|
-
* @param {boolean} [maintainCase=false]
|
|
15915
|
-
* Keep the current case, otherwise make all lowercase
|
|
15916
|
-
* @return {string}
|
|
15917
|
-
* A unique slug string
|
|
15918
|
-
*/
|
|
15919
|
-
slug(value, maintainCase) {
|
|
15920
|
-
const self2 = this;
|
|
15921
|
-
let result = slug(value, maintainCase === true);
|
|
15922
|
-
const originalSlug = result;
|
|
15923
|
-
while (own$2.call(self2.occurrences, result)) {
|
|
15924
|
-
self2.occurrences[originalSlug]++;
|
|
15925
|
-
result = originalSlug + "-" + self2.occurrences[originalSlug];
|
|
15926
|
-
}
|
|
15927
|
-
self2.occurrences[result] = 0;
|
|
15928
|
-
return result;
|
|
15929
|
-
}
|
|
15930
|
-
/**
|
|
15931
|
-
* Reset - Forget all previous slugs
|
|
15932
|
-
*
|
|
15933
|
-
* @return void
|
|
15934
|
-
*/
|
|
15935
|
-
reset() {
|
|
15936
|
-
this.occurrences = /* @__PURE__ */ Object.create(null);
|
|
15937
|
-
}
|
|
15938
|
-
}
|
|
15939
|
-
function slug(value, maintainCase) {
|
|
15940
|
-
if (typeof value !== "string") return "";
|
|
15941
|
-
if (!maintainCase) value = value.toLowerCase();
|
|
15942
|
-
return value.replace(regex, "").replace(/ /g, "-");
|
|
15849
|
+
function headingRank(node2) {
|
|
15850
|
+
const name = node2.type === "element" ? node2.tagName.toLowerCase() : "";
|
|
15851
|
+
const code2 = name.length === 2 && name.charCodeAt(0) === 104 ? name.charCodeAt(1) : 0;
|
|
15852
|
+
return code2 > 48 && code2 < 55 ? code2 - 48 : void 0;
|
|
15943
15853
|
}
|
|
15944
15854
|
function toString(node2) {
|
|
15945
15855
|
if ("children" in node2) {
|
|
@@ -16168,7 +16078,7 @@ function exitLiteralAutolinkHttp(token) {
|
|
|
16168
16078
|
function exitLiteralAutolinkWww(token) {
|
|
16169
16079
|
this.config.exit.data.call(this, token);
|
|
16170
16080
|
const node2 = this.stack[this.stack.length - 1];
|
|
16171
|
-
ok(node2.type === "link");
|
|
16081
|
+
ok$1(node2.type === "link");
|
|
16172
16082
|
node2.url = "http://" + this.sliceSerialize(token);
|
|
16173
16083
|
}
|
|
16174
16084
|
function exitLiteralAutolinkEmail(token) {
|
|
@@ -16280,7 +16190,7 @@ function enterFootnoteDefinition(token) {
|
|
|
16280
16190
|
function exitFootnoteCallString(token) {
|
|
16281
16191
|
const label = this.resume();
|
|
16282
16192
|
const node2 = this.stack[this.stack.length - 1];
|
|
16283
|
-
ok(node2.type === "footnoteReference");
|
|
16193
|
+
ok$1(node2.type === "footnoteReference");
|
|
16284
16194
|
node2.identifier = normalizeIdentifier(
|
|
16285
16195
|
this.sliceSerialize(token)
|
|
16286
16196
|
).toLowerCase();
|
|
@@ -16292,7 +16202,7 @@ function exitFootnoteCall(token) {
|
|
|
16292
16202
|
function exitFootnoteDefinitionLabelString(token) {
|
|
16293
16203
|
const label = this.resume();
|
|
16294
16204
|
const node2 = this.stack[this.stack.length - 1];
|
|
16295
|
-
ok(node2.type === "footnoteDefinition");
|
|
16205
|
+
ok$1(node2.type === "footnoteDefinition");
|
|
16296
16206
|
node2.identifier = normalizeIdentifier(
|
|
16297
16207
|
this.sliceSerialize(token)
|
|
16298
16208
|
).toLowerCase();
|
|
@@ -17981,7 +17891,7 @@ function exitCodeText(token) {
|
|
|
17981
17891
|
value = value.replace(/\\([\\|])/g, replace);
|
|
17982
17892
|
}
|
|
17983
17893
|
const node2 = this.stack[this.stack.length - 1];
|
|
17984
|
-
ok(node2.type === "inlineCode");
|
|
17894
|
+
ok$1(node2.type === "inlineCode");
|
|
17985
17895
|
node2.value = value;
|
|
17986
17896
|
this.exit(token);
|
|
17987
17897
|
}
|
|
@@ -18016,7 +17926,7 @@ function gfmTableToMarkdown(options) {
|
|
|
18016
17926
|
handlers: {
|
|
18017
17927
|
inlineCode: inlineCodeWithTable,
|
|
18018
17928
|
table: handleTable,
|
|
18019
|
-
tableCell:
|
|
17929
|
+
tableCell: handleTableCell2,
|
|
18020
17930
|
tableRow: handleTableRow
|
|
18021
17931
|
}
|
|
18022
17932
|
};
|
|
@@ -18028,7 +17938,7 @@ function gfmTableToMarkdown(options) {
|
|
|
18028
17938
|
const value = serializeData([row2]);
|
|
18029
17939
|
return value.slice(0, value.indexOf("\n"));
|
|
18030
17940
|
}
|
|
18031
|
-
function
|
|
17941
|
+
function handleTableCell2(node2, _, state, info) {
|
|
18032
17942
|
const exit2 = state.enter("tableCell");
|
|
18033
17943
|
const subexit = state.enter("phrasing");
|
|
18034
17944
|
const value = state.containerPhrasing(node2, {
|
|
@@ -18068,7 +17978,7 @@ function gfmTableToMarkdown(options) {
|
|
|
18068
17978
|
const result = [];
|
|
18069
17979
|
const subexit = state.enter("tableRow");
|
|
18070
17980
|
while (++index2 < children.length) {
|
|
18071
|
-
result[index2] =
|
|
17981
|
+
result[index2] = handleTableCell2(children[index2], node2, state, info);
|
|
18072
17982
|
}
|
|
18073
17983
|
subexit();
|
|
18074
17984
|
return result;
|
|
@@ -18098,14 +18008,14 @@ function gfmTaskListItemToMarkdown() {
|
|
|
18098
18008
|
}
|
|
18099
18009
|
function exitCheck(token) {
|
|
18100
18010
|
const node2 = this.stack[this.stack.length - 2];
|
|
18101
|
-
ok(node2.type === "listItem");
|
|
18011
|
+
ok$1(node2.type === "listItem");
|
|
18102
18012
|
node2.checked = token.type === "taskListCheckValueChecked";
|
|
18103
18013
|
}
|
|
18104
18014
|
function exitParagraphWithTaskListItem(token) {
|
|
18105
18015
|
const parent = this.stack[this.stack.length - 2];
|
|
18106
18016
|
if (parent && parent.type === "listItem" && typeof parent.checked === "boolean") {
|
|
18107
18017
|
const node2 = this.stack[this.stack.length - 1];
|
|
18108
|
-
ok(node2.type === "paragraph");
|
|
18018
|
+
ok$1(node2.type === "paragraph");
|
|
18109
18019
|
const head2 = node2.children[0];
|
|
18110
18020
|
if (head2 && head2.type === "text") {
|
|
18111
18021
|
const siblings2 = parent.children;
|
|
@@ -19639,7 +19549,7 @@ function requireExtend() {
|
|
|
19639
19549
|
return obj[name];
|
|
19640
19550
|
};
|
|
19641
19551
|
extend$1 = function extend2() {
|
|
19642
|
-
var options, name, src, copy, copyIsArray,
|
|
19552
|
+
var options, name, src, copy, copyIsArray, clone;
|
|
19643
19553
|
var target = arguments[0];
|
|
19644
19554
|
var i = 1;
|
|
19645
19555
|
var length = arguments.length;
|
|
@@ -19662,11 +19572,11 @@ function requireExtend() {
|
|
|
19662
19572
|
if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
|
|
19663
19573
|
if (copyIsArray) {
|
|
19664
19574
|
copyIsArray = false;
|
|
19665
|
-
|
|
19575
|
+
clone = src && isArray(src) ? src : [];
|
|
19666
19576
|
} else {
|
|
19667
|
-
|
|
19577
|
+
clone = src && isPlainObject2(src) ? src : {};
|
|
19668
19578
|
}
|
|
19669
|
-
setProperty(target, { name, newValue: extend2(deep,
|
|
19579
|
+
setProperty(target, { name, newValue: extend2(deep, clone, copy) });
|
|
19670
19580
|
} else if (typeof copy !== "undefined") {
|
|
19671
19581
|
setProperty(target, { name, newValue: copy });
|
|
19672
19582
|
}
|
|
@@ -20422,42 +20332,6 @@ function isUint8Array(value) {
|
|
|
20422
20332
|
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
|
20423
20333
|
);
|
|
20424
20334
|
}
|
|
20425
|
-
const rehypeSanitizeHtml = () => {
|
|
20426
|
-
return (tree) => {
|
|
20427
|
-
visit(tree, (node2, index2, parent) => {
|
|
20428
|
-
if (!parent || typeof index2 !== "number") {
|
|
20429
|
-
return;
|
|
20430
|
-
}
|
|
20431
|
-
if (node2.type === "comment" && node2.value.trim() === "") {
|
|
20432
|
-
parent.children.splice(index2, 1);
|
|
20433
|
-
return index2;
|
|
20434
|
-
}
|
|
20435
|
-
if (node2.type === "element" && node2.children) {
|
|
20436
|
-
const newChildren = [];
|
|
20437
|
-
let textBuffer = "";
|
|
20438
|
-
const flushTextBuffer = () => {
|
|
20439
|
-
if (textBuffer) {
|
|
20440
|
-
const cleanedText = textBuffer.replace(/\s+/g, " ");
|
|
20441
|
-
newChildren.push({ type: "text", value: cleanedText });
|
|
20442
|
-
textBuffer = "";
|
|
20443
|
-
}
|
|
20444
|
-
};
|
|
20445
|
-
for (const child of node2.children) {
|
|
20446
|
-
if (child.type === "text") {
|
|
20447
|
-
textBuffer += child.value;
|
|
20448
|
-
} else if (child.type === "comment" && child.value.trim() === "") {
|
|
20449
|
-
continue;
|
|
20450
|
-
} else {
|
|
20451
|
-
flushTextBuffer();
|
|
20452
|
-
newChildren.push(child);
|
|
20453
|
-
}
|
|
20454
|
-
}
|
|
20455
|
-
flushTextBuffer();
|
|
20456
|
-
node2.children = newChildren;
|
|
20457
|
-
}
|
|
20458
|
-
});
|
|
20459
|
-
};
|
|
20460
|
-
};
|
|
20461
20335
|
const rehypeAbsoluteLinks = (options) => {
|
|
20462
20336
|
const { baseUrl } = options;
|
|
20463
20337
|
const tagAttributeMap = {
|
|
@@ -20494,13 +20368,11 @@ const rehypeAbsoluteLinks = (options) => {
|
|
|
20494
20368
|
const trimmedPart = part.trim();
|
|
20495
20369
|
if (!trimmedPart) return "";
|
|
20496
20370
|
const parts = trimmedPart.split(/\s+/);
|
|
20371
|
+
if (parts.length === 0) return "";
|
|
20497
20372
|
const url = parts[0];
|
|
20498
|
-
const
|
|
20499
|
-
|
|
20500
|
-
|
|
20501
|
-
return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
|
|
20502
|
-
}
|
|
20503
|
-
return trimmedPart;
|
|
20373
|
+
const absoluteUrl = resolveUrl(url);
|
|
20374
|
+
parts[0] = absoluteUrl;
|
|
20375
|
+
return parts.join(" ");
|
|
20504
20376
|
}).filter(Boolean).join(", ");
|
|
20505
20377
|
node2.properties[attr] = newSrcset;
|
|
20506
20378
|
} else {
|
|
@@ -20512,6 +20384,41 @@ const rehypeAbsoluteLinks = (options) => {
|
|
|
20512
20384
|
});
|
|
20513
20385
|
};
|
|
20514
20386
|
};
|
|
20387
|
+
const rehypeSanitizeHtml = () => {
|
|
20388
|
+
return (tree) => {
|
|
20389
|
+
visit(tree, (node2, index2, parent) => {
|
|
20390
|
+
if (!parent || typeof index2 !== "number") {
|
|
20391
|
+
return;
|
|
20392
|
+
}
|
|
20393
|
+
if (node2.type === "comment" && node2.value.trim() === "") {
|
|
20394
|
+
parent.children.splice(index2, 1);
|
|
20395
|
+
return index2;
|
|
20396
|
+
}
|
|
20397
|
+
if (node2.type === "element" && node2.children) {
|
|
20398
|
+
const newChildren = [];
|
|
20399
|
+
let textBuffer = "";
|
|
20400
|
+
const flushTextBuffer = () => {
|
|
20401
|
+
if (textBuffer) {
|
|
20402
|
+
const cleanedText = textBuffer.replace(/\s+/g, " ");
|
|
20403
|
+
newChildren.push({ type: "text", value: cleanedText });
|
|
20404
|
+
textBuffer = "";
|
|
20405
|
+
}
|
|
20406
|
+
};
|
|
20407
|
+
for (const child of node2.children) {
|
|
20408
|
+
if (child.type === "text") {
|
|
20409
|
+
textBuffer += child.value;
|
|
20410
|
+
} else if (child.type === "comment" && child.value.trim() === "") ;
|
|
20411
|
+
else {
|
|
20412
|
+
flushTextBuffer();
|
|
20413
|
+
newChildren.push(child);
|
|
20414
|
+
}
|
|
20415
|
+
}
|
|
20416
|
+
flushTextBuffer();
|
|
20417
|
+
node2.children = newChildren;
|
|
20418
|
+
}
|
|
20419
|
+
});
|
|
20420
|
+
};
|
|
20421
|
+
};
|
|
20515
20422
|
const rehypeWikipediaFootnotes = () => {
|
|
20516
20423
|
return (tree) => {
|
|
20517
20424
|
const footnotes = [];
|
|
@@ -20569,22 +20476,82 @@ const rehypeWikipediaFootnotes = () => {
|
|
|
20569
20476
|
}
|
|
20570
20477
|
};
|
|
20571
20478
|
};
|
|
20479
|
+
const handleTableCell = (_state, node2, _parent) => {
|
|
20480
|
+
const allowedTags = ["br", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "strong", "em", "b", "i", "u", "s", "strike", "del", "ins", "code", "ul", "ol", "li", "a", "img", "blockquote", "pre", "table", "thead", "tbody", "tfoot", "tr", "th", "td"];
|
|
20481
|
+
const allowedAttributes = ["style", "class", "id", "colspan", "rowspan", "width", "height", "align", "href", "src", "title", "alt"];
|
|
20482
|
+
visit(node2, "element", (elementNode, index2, parent) => {
|
|
20483
|
+
if (!parent || typeof index2 !== "number") {
|
|
20484
|
+
return;
|
|
20485
|
+
}
|
|
20486
|
+
if (elementNode.tagName === "div") {
|
|
20487
|
+
const style2 = elementNode.properties?.style;
|
|
20488
|
+
const isHorizontalLayout = /display:\s*(inline-block|flex|inline-flex)|float:\s*(left|right)/.test(style2 ?? "");
|
|
20489
|
+
if (isHorizontalLayout) {
|
|
20490
|
+
for (const child of elementNode.children) {
|
|
20491
|
+
if (child.type === "element" && child.tagName === "div") {
|
|
20492
|
+
child.tagName = "span";
|
|
20493
|
+
}
|
|
20494
|
+
}
|
|
20495
|
+
const newChildren = [];
|
|
20496
|
+
const separator = { type: "text", value: " " };
|
|
20497
|
+
elementNode.children.forEach((child, i) => {
|
|
20498
|
+
newChildren.push(child);
|
|
20499
|
+
if (i < elementNode.children.length - 1) {
|
|
20500
|
+
newChildren.push(separator);
|
|
20501
|
+
}
|
|
20502
|
+
});
|
|
20503
|
+
parent.children.splice(index2, 1, ...newChildren);
|
|
20504
|
+
return index2;
|
|
20505
|
+
}
|
|
20506
|
+
const brNode = { type: "element", tagName: "br", properties: {}, children: [] };
|
|
20507
|
+
const nodesToInsert = [...elementNode.children];
|
|
20508
|
+
const prevNode = parent.children[index2 - 1];
|
|
20509
|
+
const nextNode = parent.children[index2 + 1];
|
|
20510
|
+
const prevIsBr = prevNode && prevNode.type === "element" && prevNode.tagName === "br";
|
|
20511
|
+
const nextIsBr = nextNode && nextNode.type === "element" && nextNode.tagName === "br";
|
|
20512
|
+
if (prevIsBr !== void 0 && !prevIsBr) {
|
|
20513
|
+
nodesToInsert.unshift(brNode);
|
|
20514
|
+
}
|
|
20515
|
+
if (nextIsBr !== void 0 && !nextIsBr) {
|
|
20516
|
+
nodesToInsert.push(brNode);
|
|
20517
|
+
}
|
|
20518
|
+
parent.children.splice(index2, 1, ...nodesToInsert);
|
|
20519
|
+
return index2;
|
|
20520
|
+
}
|
|
20521
|
+
if (!allowedTags.includes(elementNode.tagName)) {
|
|
20522
|
+
parent.children.splice(index2, 1, ...elementNode.children);
|
|
20523
|
+
return index2;
|
|
20524
|
+
}
|
|
20525
|
+
if (elementNode.properties) {
|
|
20526
|
+
Object.keys(elementNode.properties).forEach((key2) => {
|
|
20527
|
+
if (!allowedAttributes.includes(key2)) {
|
|
20528
|
+
delete elementNode.properties[key2];
|
|
20529
|
+
}
|
|
20530
|
+
});
|
|
20531
|
+
}
|
|
20532
|
+
});
|
|
20533
|
+
const value = toHtml(node2.children, { allowDangerousHtml: true });
|
|
20534
|
+
return { type: "tableCell", children: [{ type: "html", value }] };
|
|
20535
|
+
};
|
|
20572
20536
|
const convertHtmlToMarkdown = async (html2, baseUrl, locale) => {
|
|
20573
20537
|
console.log(getMessage(locale, "convert_start"));
|
|
20574
|
-
const
|
|
20538
|
+
const slugger = new BananaSlug();
|
|
20539
|
+
const file = await unified().use(rehypeParse, { fragment: true }).use(rehypeRaw).use(rehypeSanitizeHtml).use(rehypeSlug).use(rehypeAbsoluteLinks, { baseUrl }).use(rehypeWikipediaFootnotes).use(rehypeRemark, {
|
|
20575
20540
|
handlers: {
|
|
20576
20541
|
a(state, node2) {
|
|
20577
20542
|
const hasComplexChildren = node2.children.some((child) => child.type === "element" && ["dl", "ul", "ol", "table", "div"].includes(child.tagName));
|
|
20578
20543
|
if (hasComplexChildren && node2.properties?.href) {
|
|
20579
20544
|
const linkText2 = String(node2.properties.ariaLabel || "");
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20545
|
+
if (linkText2) {
|
|
20546
|
+
const url2 = String(node2.properties.href);
|
|
20547
|
+
const linkNode = {
|
|
20548
|
+
type: "link",
|
|
20549
|
+
url: url2,
|
|
20550
|
+
children: [{ type: "text", value: linkText2 }]
|
|
20551
|
+
};
|
|
20552
|
+
const otherContent = state.all(node2);
|
|
20553
|
+
return [linkNode, { type: "text", value: "\n" }, ...otherContent];
|
|
20554
|
+
}
|
|
20588
20555
|
}
|
|
20589
20556
|
const extractTextFromHast = (n) => {
|
|
20590
20557
|
if (n.type === "text") {
|
|
@@ -20596,8 +20563,12 @@ const convertHtmlToMarkdown = async (html2, baseUrl, locale) => {
|
|
|
20596
20563
|
return "";
|
|
20597
20564
|
};
|
|
20598
20565
|
let linkText = extractTextFromHast(node2).replace(/\s+/g, " ").trim();
|
|
20599
|
-
if (!linkText
|
|
20600
|
-
|
|
20566
|
+
if (!linkText) {
|
|
20567
|
+
const props = node2.properties || {};
|
|
20568
|
+
linkText = String(props.ariaLabel || props.title || props.href || "");
|
|
20569
|
+
}
|
|
20570
|
+
if (!linkText) {
|
|
20571
|
+
return state.all(node2);
|
|
20601
20572
|
}
|
|
20602
20573
|
const containsImage = (hastNode) => {
|
|
20603
20574
|
if (!hastNode.children) return false;
|
|
@@ -20621,96 +20592,22 @@ const convertHtmlToMarkdown = async (html2, baseUrl, locale) => {
|
|
|
20621
20592
|
children: state.all(node2)
|
|
20622
20593
|
};
|
|
20623
20594
|
}
|
|
20595
|
+
let url = String(node2.properties?.href || "");
|
|
20596
|
+
if (url.startsWith("#")) {
|
|
20597
|
+
url = `#${slugger.slug(url.substring(1))}`;
|
|
20598
|
+
}
|
|
20624
20599
|
return {
|
|
20625
20600
|
type: "link",
|
|
20626
|
-
url
|
|
20601
|
+
url,
|
|
20627
20602
|
title: node2.properties?.title ? String(node2.properties.title) : null,
|
|
20628
20603
|
children: [{ type: "text", value: linkText }]
|
|
20629
20604
|
};
|
|
20630
20605
|
},
|
|
20631
|
-
td(state, node2) {
|
|
20632
|
-
|
|
20633
|
-
const allowedAttributes = ["style", "class", "id", "colspan", "rowspan", "width", "height", "align", "href", "src", "title", "alt"];
|
|
20634
|
-
visit(node2, "element", (elementNode, index2, parent) => {
|
|
20635
|
-
if (!parent || typeof index2 !== "number") {
|
|
20636
|
-
return;
|
|
20637
|
-
}
|
|
20638
|
-
if (elementNode.tagName === "div") {
|
|
20639
|
-
const brNode = { type: "element", tagName: "br", properties: {}, children: [] };
|
|
20640
|
-
let nodesToInsert = [...elementNode.children];
|
|
20641
|
-
const style2 = elementNode.properties?.style;
|
|
20642
|
-
const isHorizontalLayout = style2 ? /display:\s*(inline-block|flex|inline-flex)|float:\s*(left|right)/.test(style2) : false;
|
|
20643
|
-
if (!isHorizontalLayout) {
|
|
20644
|
-
const prevNode = parent.children[index2 - 1];
|
|
20645
|
-
const nextNode = parent.children[index2 + 1];
|
|
20646
|
-
const prevIsBr = prevNode && prevNode.type === "element" && prevNode.tagName === "br";
|
|
20647
|
-
const nextIsBr = nextNode && nextNode.type === "element" && nextNode.tagName === "br";
|
|
20648
|
-
if (index2 > 0 && !prevIsBr) {
|
|
20649
|
-
nodesToInsert.unshift(brNode);
|
|
20650
|
-
}
|
|
20651
|
-
if (index2 < parent.children.length - 1 && !nextIsBr) {
|
|
20652
|
-
nodesToInsert.push(brNode);
|
|
20653
|
-
}
|
|
20654
|
-
}
|
|
20655
|
-
parent.children.splice(index2, 1, ...nodesToInsert);
|
|
20656
|
-
return index2;
|
|
20657
|
-
}
|
|
20658
|
-
if (!allowedTags.includes(elementNode.tagName)) {
|
|
20659
|
-
parent.children.splice(index2, 1, ...elementNode.children);
|
|
20660
|
-
return index2;
|
|
20661
|
-
}
|
|
20662
|
-
if (elementNode.properties) {
|
|
20663
|
-
Object.keys(elementNode.properties).forEach((key2) => {
|
|
20664
|
-
if (!allowedAttributes.includes(key2)) {
|
|
20665
|
-
delete elementNode.properties[key2];
|
|
20666
|
-
}
|
|
20667
|
-
});
|
|
20668
|
-
}
|
|
20669
|
-
});
|
|
20670
|
-
const value = toHtml(node2.children, { allowDangerousHtml: true });
|
|
20671
|
-
return { type: "tableCell", children: [{ type: "html", value }] };
|
|
20606
|
+
td(state, node2, parent) {
|
|
20607
|
+
return handleTableCell(state, node2);
|
|
20672
20608
|
},
|
|
20673
|
-
th(state, node2) {
|
|
20674
|
-
|
|
20675
|
-
const allowedAttributes = ["style", "class", "id", "colspan", "rowspan", "width", "height", "align", "href", "src", "title", "alt"];
|
|
20676
|
-
visit(node2, "element", (elementNode, index2, parent) => {
|
|
20677
|
-
if (!parent || typeof index2 !== "number") {
|
|
20678
|
-
return;
|
|
20679
|
-
}
|
|
20680
|
-
if (elementNode.tagName === "div") {
|
|
20681
|
-
const brNode = { type: "element", tagName: "br", properties: {}, children: [] };
|
|
20682
|
-
let nodesToInsert = [...elementNode.children];
|
|
20683
|
-
const style2 = elementNode.properties?.style;
|
|
20684
|
-
const isHorizontalLayout = style2 ? /display:\s*(inline-block|flex|inline-flex)|float:\s*(left|right)/.test(style2) : false;
|
|
20685
|
-
if (!isHorizontalLayout) {
|
|
20686
|
-
const prevNode = parent.children[index2 - 1];
|
|
20687
|
-
const nextNode = parent.children[index2 + 1];
|
|
20688
|
-
const prevIsBr = prevNode && prevNode.type === "element" && prevNode.tagName === "br";
|
|
20689
|
-
const nextIsBr = nextNode && nextNode.type === "element" && nextNode.tagName === "br";
|
|
20690
|
-
if (index2 > 0 && !prevIsBr) {
|
|
20691
|
-
nodesToInsert.unshift(brNode);
|
|
20692
|
-
}
|
|
20693
|
-
if (index2 < parent.children.length - 1 && !nextIsBr) {
|
|
20694
|
-
nodesToInsert.push(brNode);
|
|
20695
|
-
}
|
|
20696
|
-
}
|
|
20697
|
-
parent.children.splice(index2, 1, ...nodesToInsert);
|
|
20698
|
-
return index2;
|
|
20699
|
-
}
|
|
20700
|
-
if (!allowedTags.includes(elementNode.tagName)) {
|
|
20701
|
-
parent.children.splice(index2, 1, ...elementNode.children);
|
|
20702
|
-
return index2;
|
|
20703
|
-
}
|
|
20704
|
-
if (elementNode.properties) {
|
|
20705
|
-
Object.keys(elementNode.properties).forEach((key2) => {
|
|
20706
|
-
if (!allowedAttributes.includes(key2)) {
|
|
20707
|
-
delete elementNode.properties[key2];
|
|
20708
|
-
}
|
|
20709
|
-
});
|
|
20710
|
-
}
|
|
20711
|
-
});
|
|
20712
|
-
const value = toHtml(node2.children, { allowDangerousHtml: true });
|
|
20713
|
-
return { type: "tableCell", children: [{ type: "html", value }] };
|
|
20609
|
+
th(state, node2, parent) {
|
|
20610
|
+
return handleTableCell(state, node2);
|
|
20714
20611
|
}
|
|
20715
20612
|
}
|
|
20716
20613
|
}).use(remarkGfm).use(remarkStringify, {
|
|
@@ -20729,15 +20626,20 @@ const convertHtmlToMarkdown = async (html2, baseUrl, locale) => {
|
|
|
20729
20626
|
return correctedMarkdown;
|
|
20730
20627
|
};
|
|
20731
20628
|
const htmlToMarkdown = async (url, options = {}) => {
|
|
20629
|
+
const { locale = "en-US" } = options;
|
|
20732
20630
|
try {
|
|
20733
20631
|
new URL(url);
|
|
20734
|
-
|
|
20735
|
-
|
|
20632
|
+
const htmlContent = await getHtmlWithPlaywright(url, locale);
|
|
20633
|
+
if (!htmlContent) {
|
|
20634
|
+
console.error(`No HTML content found for URL: ${url}`);
|
|
20635
|
+
return "";
|
|
20636
|
+
}
|
|
20637
|
+
const markdown = await convertHtmlToMarkdown(htmlContent, url, locale);
|
|
20638
|
+
return markdown;
|
|
20639
|
+
} catch (error) {
|
|
20640
|
+
console.error(`An error occurred during the conversion process for URL: ${url}`, error);
|
|
20641
|
+
return "";
|
|
20736
20642
|
}
|
|
20737
|
-
const { locale = "en-US" } = options;
|
|
20738
|
-
const htmlContent = await getHtmlWithPlaywright(url, locale);
|
|
20739
|
-
const markdown = await convertHtmlToMarkdown(htmlContent, url, locale);
|
|
20740
|
-
return markdown;
|
|
20741
20643
|
};
|
|
20742
20644
|
export {
|
|
20743
20645
|
getMessage as g,
|