@clevertask/scribe 0.0.15 → 0.1.1

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.
Files changed (66) hide show
  1. package/README.md +77 -27
  2. package/dist/BarMenu-DaKIz3zZ.js +327 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts +0 -1
  5. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  6. package/dist/components/Menu/BarMenu.js +8 -140
  7. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  8. package/dist/components/Menu/BubbleMenu.js +2074 -159
  9. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  10. package/dist/components/Menu/Mobile/ListOptionBar.js +42 -22
  11. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts +19 -1
  12. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts.map +1 -1
  13. package/dist/components/Scribe/extension/emoji/EmojiList.js +42 -42
  14. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -4
  15. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  16. package/dist/components/Scribe/extension/emoji/suggest.js +20 -15
  17. package/dist/components/Scribe/extension/extension-link.js +2 -984
  18. package/dist/components/Scribe/extension/extension-markdown-paste.js +4 -4
  19. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  20. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts +3 -0
  21. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -0
  22. package/dist/components/Scribe/extension/getPopupMountTarget.js +16 -0
  23. package/dist/components/Scribe/extension/index.d.ts +16 -2
  24. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/index.js +37122 -34
  26. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts +4 -1
  27. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts.map +1 -1
  28. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3730 -14
  29. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  30. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +1 -1
  31. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  32. package/dist/components/Scribe/extension/slashCommand/renderItems.js +21 -16
  33. package/dist/components/Scribe/extension/tableOfContents.d.ts +48 -0
  34. package/dist/components/Scribe/extension/tableOfContents.d.ts.map +1 -0
  35. package/dist/components/Scribe/extension/tableOfContents.js +180 -0
  36. package/dist/components/Scribe/index.d.ts +12 -1
  37. package/dist/components/Scribe/index.d.ts.map +1 -1
  38. package/dist/components/Scribe/index.js +133 -87
  39. package/dist/extension-link-Ch_T7WWG.js +1030 -0
  40. package/dist/icons/ToolbarIcons.d.ts +19 -0
  41. package/dist/icons/ToolbarIcons.d.ts.map +1 -0
  42. package/dist/icons/ToolbarIcons.js +135 -0
  43. package/dist/{index-BKFDqQPh.js → index-BiBV5TQx.js} +6598 -5432
  44. package/dist/index-CqzMmrnw.js +1410 -0
  45. package/dist/index-DxF-1P4n.js +834 -0
  46. package/dist/index-V-gN11Y9.js +249 -0
  47. package/dist/main.css +200 -1123
  48. package/dist/main.js +1 -1
  49. package/dist/markdown-to-html-pL7ckd-m.js +1135 -0
  50. package/dist/purify.es-exIQuqhb.js +595 -0
  51. package/dist/tippy.esm-DLHdsnfG.js +1711 -0
  52. package/dist/utils/create-scribe-editor.d.ts +2 -2
  53. package/dist/utils/create-scribe-editor.d.ts.map +1 -1
  54. package/dist/utils/create-scribe-editor.js +3 -3
  55. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  56. package/dist/utils/html-to-markdown.js +583 -18
  57. package/dist/utils/index.js +1 -1
  58. package/dist/utils/markdown-to-html.js +2 -2
  59. package/package.json +34 -37
  60. package/dist/clsx-OuTLNxxd.js +0 -16
  61. package/dist/index-CL2WLiGu.js +0 -159
  62. package/dist/index-Cxf4VEm1.js +0 -50957
  63. package/dist/index-PzbCrHp0.js +0 -2349
  64. package/dist/markdown-to-html-__93dwok.js +0 -1557
  65. package/dist/purify.es-BPDBzHtc.js +0 -552
  66. package/dist/turndown.browser.es-RmA_HBaI.js +0 -649
@@ -1,1557 +0,0 @@
1
- import { p as xe } from "./purify.es-BPDBzHtc.js";
2
- function O() {
3
- return {
4
- async: !1,
5
- breaks: !1,
6
- extensions: null,
7
- gfm: !0,
8
- hooks: null,
9
- pedantic: !1,
10
- renderer: null,
11
- silent: !1,
12
- tokenizer: null,
13
- walkTokens: null
14
- };
15
- }
16
- var S = O();
17
- function ie(n) {
18
- S = n;
19
- }
20
- var z = { exec: () => null };
21
- function u(n, e = "") {
22
- let t = typeof n == "string" ? n : n.source;
23
- const s = {
24
- replace: (r, i) => {
25
- let l = typeof i == "string" ? i : i.source;
26
- return l = l.replace(x.caret, "$1"), t = t.replace(r, l), s;
27
- },
28
- getRegex: () => new RegExp(t, e)
29
- };
30
- return s;
31
- }
32
- var x = {
33
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
34
- outputLinkReplace: /\\([\[\]])/g,
35
- indentCodeCompensation: /^(\s+)(?:```)/,
36
- beginningSpace: /^\s+/,
37
- endingHash: /#$/,
38
- startingSpaceChar: /^ /,
39
- endingSpaceChar: / $/,
40
- nonSpaceChar: /[^ ]/,
41
- newLineCharGlobal: /\n/g,
42
- tabCharGlobal: /\t/g,
43
- multipleSpaceGlobal: /\s+/g,
44
- blankLine: /^[ \t]*$/,
45
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
46
- blockquoteStart: /^ {0,3}>/,
47
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
48
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
49
- listReplaceTabs: /^\t+/,
50
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
51
- listIsTask: /^\[[ xX]\] /,
52
- listReplaceTask: /^\[[ xX]\] +/,
53
- anyLine: /\n.*\n/,
54
- hrefBrackets: /^<(.*)>$/,
55
- tableDelimiter: /[:|]/,
56
- tableAlignChars: /^\||\| *$/g,
57
- tableRowBlankLine: /\n[ \t]*$/,
58
- tableAlignRight: /^ *-+: *$/,
59
- tableAlignCenter: /^ *:-+: *$/,
60
- tableAlignLeft: /^ *:-+ *$/,
61
- startATag: /^<a /i,
62
- endATag: /^<\/a>/i,
63
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
64
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
65
- startAngleBracket: /^</,
66
- endAngleBracket: />$/,
67
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
68
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
69
- escapeTest: /[&<>"']/,
70
- escapeReplace: /[&<>"']/g,
71
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
72
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
73
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
74
- caret: /(^|[^\[])\^/g,
75
- percentDecode: /%25/g,
76
- findPipe: /\|/g,
77
- splitPipe: / \|/,
78
- slashPipe: /\\\|/g,
79
- carriageReturn: /\r\n|\r/g,
80
- spaceLine: /^ +$/gm,
81
- notSpaceStart: /^\S*/,
82
- endingNewline: /\n$/,
83
- listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
84
- nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
85
- hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
86
- fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
87
- headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
88
- htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
89
- }, be = /^(?:[ \t]*(?:\n|$))+/, me = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, _ = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, N = /(?:[*+-]|\d{1,9}[.)])/, le = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ae = u(le).replace(/bull/g, N).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex(), Re = u(le).replace(/bull/g, N).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Se = /^[^\n]+/, H = /(?!\s*\])(?:\\.|[^\[\]\\])+/, $e = u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", H).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Te = u(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, N).getRegex(), B = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", Q = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, ve = u(
90
- "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
91
- "i"
92
- ).replace("comment", Q).replace("tag", B).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), oe = u(j).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex(), ze = u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", oe).getRegex(), F = {
93
- blockquote: ze,
94
- code: me,
95
- def: $e,
96
- fences: we,
97
- heading: ye,
98
- hr: _,
99
- html: ve,
100
- lheading: ae,
101
- list: Te,
102
- newline: be,
103
- paragraph: oe,
104
- table: z,
105
- text: Se
106
- }, ee = u(
107
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
108
- ).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex(), _e = {
109
- ...F,
110
- lheading: Re,
111
- table: ee,
112
- paragraph: u(j).replace("hr", _).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ee).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", B).getRegex()
113
- }, Ae = {
114
- ...F,
115
- html: u(
116
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
117
- ).replace("comment", Q).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
118
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
119
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
120
- fences: z,
121
- // fences not supported
122
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
123
- paragraph: u(j).replace("hr", _).replace("heading", ` *#{1,6} *[^
124
- ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
125
- }, Le = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ce = /^( {2,}|\\)\n(?!\s*$)/, Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, E = /[\p{P}\p{S}]/u, U = /[\s\p{P}\p{S}]/u, he = /[^\s\p{P}\p{S}]/u, Pe = u(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, U).getRegex(), pe = /(?!~)[\p{P}\p{S}]/u, Be = /(?!~)[\s\p{P}\p{S}]/u, Ee = /(?:[^\s\p{P}\p{S}]|~)/u, qe = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, ue = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Ze = u(ue, "u").replace(/punct/g, E).getRegex(), De = u(ue, "u").replace(/punct/g, pe).getRegex(), ge = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Me = u(ge, "gu").replace(/notPunctSpace/g, he).replace(/punctSpace/g, U).replace(/punct/g, E).getRegex(), Ge = u(ge, "gu").replace(/notPunctSpace/g, Ee).replace(/punctSpace/g, Be).replace(/punct/g, pe).getRegex(), Oe = u(
126
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
127
- "gu"
128
- ).replace(/notPunctSpace/g, he).replace(/punctSpace/g, U).replace(/punct/g, E).getRegex(), Ne = u(/\\(punct)/, "gu").replace(/punct/g, E).getRegex(), je = u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), He = u(Q).replace("(?:-->|$)", "-->").getRegex(), Qe = u(
129
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
130
- ).replace("comment", He).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), C = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, Fe = u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", C).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), fe = u(/^!?\[(label)\]\[(ref)\]/).replace("label", C).replace("ref", H).getRegex(), ke = u(/^!?\[(ref)\](?:\[\])?/).replace("ref", H).getRegex(), Ue = u("reflink|nolink(?!\\()", "g").replace("reflink", fe).replace("nolink", ke).getRegex(), X = {
131
- _backpedal: z,
132
- // only used for GFM url
133
- anyPunctuation: Ne,
134
- autolink: je,
135
- blockSkip: qe,
136
- br: ce,
137
- code: Ce,
138
- del: z,
139
- emStrongLDelim: Ze,
140
- emStrongRDelimAst: Me,
141
- emStrongRDelimUnd: Oe,
142
- escape: Le,
143
- link: Fe,
144
- nolink: ke,
145
- punctuation: Pe,
146
- reflink: fe,
147
- reflinkSearch: Ue,
148
- tag: Qe,
149
- text: Ie,
150
- url: z
151
- }, Xe = {
152
- ...X,
153
- link: u(/^!?\[(label)\]\((.*?)\)/).replace("label", C).getRegex(),
154
- reflink: u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", C).getRegex()
155
- }, D = {
156
- ...X,
157
- emStrongRDelimAst: Ge,
158
- emStrongLDelim: De,
159
- url: u(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
160
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
161
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
162
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
163
- }, We = {
164
- ...D,
165
- br: u(ce).replace("{2,}", "*").getRegex(),
166
- text: u(D.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
167
- }, A = {
168
- normal: F,
169
- gfm: _e,
170
- pedantic: Ae
171
- }, T = {
172
- normal: X,
173
- gfm: D,
174
- breaks: We,
175
- pedantic: Xe
176
- }, Je = {
177
- "&": "&amp;",
178
- "<": "&lt;",
179
- ">": "&gt;",
180
- '"': "&quot;",
181
- "'": "&#39;"
182
- }, te = (n) => Je[n];
183
- function m(n, e) {
184
- if (e) {
185
- if (x.escapeTest.test(n))
186
- return n.replace(x.escapeReplace, te);
187
- } else if (x.escapeTestNoEncode.test(n))
188
- return n.replace(x.escapeReplaceNoEncode, te);
189
- return n;
190
- }
191
- function ne(n) {
192
- try {
193
- n = encodeURI(n).replace(x.percentDecode, "%");
194
- } catch {
195
- return null;
196
- }
197
- return n;
198
- }
199
- function re(n, e) {
200
- const t = n.replace(x.findPipe, (i, l, a) => {
201
- let c = !1, o = l;
202
- for (; --o >= 0 && a[o] === "\\"; ) c = !c;
203
- return c ? "|" : " |";
204
- }), s = t.split(x.splitPipe);
205
- let r = 0;
206
- if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e)
207
- if (s.length > e)
208
- s.splice(e);
209
- else
210
- for (; s.length < e; ) s.push("");
211
- for (; r < s.length; r++)
212
- s[r] = s[r].trim().replace(x.slashPipe, "|");
213
- return s;
214
- }
215
- function v(n, e, t) {
216
- const s = n.length;
217
- if (s === 0)
218
- return "";
219
- let r = 0;
220
- for (; r < s && n.charAt(s - r - 1) === e; )
221
- r++;
222
- return n.slice(0, s - r);
223
- }
224
- function Ke(n, e) {
225
- if (n.indexOf(e[1]) === -1)
226
- return -1;
227
- let t = 0;
228
- for (let s = 0; s < n.length; s++)
229
- if (n[s] === "\\")
230
- s++;
231
- else if (n[s] === e[0])
232
- t++;
233
- else if (n[s] === e[1] && (t--, t < 0))
234
- return s;
235
- return t > 0 ? -2 : -1;
236
- }
237
- function se(n, e, t, s, r) {
238
- const i = e.href, l = e.title || null, a = n[1].replace(r.other.outputLinkReplace, "$1");
239
- s.state.inLink = !0;
240
- const c = {
241
- type: n[0].charAt(0) === "!" ? "image" : "link",
242
- raw: t,
243
- href: i,
244
- title: l,
245
- text: a,
246
- tokens: s.inlineTokens(a)
247
- };
248
- return s.state.inLink = !1, c;
249
- }
250
- function Ve(n, e, t) {
251
- const s = n.match(t.other.indentCodeCompensation);
252
- if (s === null)
253
- return e;
254
- const r = s[1];
255
- return e.split(`
256
- `).map((i) => {
257
- const l = i.match(t.other.beginningSpace);
258
- if (l === null)
259
- return i;
260
- const [a] = l;
261
- return a.length >= r.length ? i.slice(r.length) : i;
262
- }).join(`
263
- `);
264
- }
265
- var I = class {
266
- options;
267
- rules;
268
- // set by the lexer
269
- lexer;
270
- // set by the lexer
271
- constructor(n) {
272
- this.options = n || S;
273
- }
274
- space(n) {
275
- const e = this.rules.block.newline.exec(n);
276
- if (e && e[0].length > 0)
277
- return {
278
- type: "space",
279
- raw: e[0]
280
- };
281
- }
282
- code(n) {
283
- const e = this.rules.block.code.exec(n);
284
- if (e) {
285
- const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
286
- return {
287
- type: "code",
288
- raw: e[0],
289
- codeBlockStyle: "indented",
290
- text: this.options.pedantic ? t : v(t, `
291
- `)
292
- };
293
- }
294
- }
295
- fences(n) {
296
- const e = this.rules.block.fences.exec(n);
297
- if (e) {
298
- const t = e[0], s = Ve(t, e[3] || "", this.rules);
299
- return {
300
- type: "code",
301
- raw: t,
302
- lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
303
- text: s
304
- };
305
- }
306
- }
307
- heading(n) {
308
- const e = this.rules.block.heading.exec(n);
309
- if (e) {
310
- let t = e[2].trim();
311
- if (this.rules.other.endingHash.test(t)) {
312
- const s = v(t, "#");
313
- (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (t = s.trim());
314
- }
315
- return {
316
- type: "heading",
317
- raw: e[0],
318
- depth: e[1].length,
319
- text: t,
320
- tokens: this.lexer.inline(t)
321
- };
322
- }
323
- }
324
- hr(n) {
325
- const e = this.rules.block.hr.exec(n);
326
- if (e)
327
- return {
328
- type: "hr",
329
- raw: v(e[0], `
330
- `)
331
- };
332
- }
333
- blockquote(n) {
334
- const e = this.rules.block.blockquote.exec(n);
335
- if (e) {
336
- let t = v(e[0], `
337
- `).split(`
338
- `), s = "", r = "";
339
- const i = [];
340
- for (; t.length > 0; ) {
341
- let l = !1;
342
- const a = [];
343
- let c;
344
- for (c = 0; c < t.length; c++)
345
- if (this.rules.other.blockquoteStart.test(t[c]))
346
- a.push(t[c]), l = !0;
347
- else if (!l)
348
- a.push(t[c]);
349
- else
350
- break;
351
- t = t.slice(c);
352
- const o = a.join(`
353
- `), h = o.replace(this.rules.other.blockquoteSetextReplace, `
354
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
355
- s = s ? `${s}
356
- ${o}` : o, r = r ? `${r}
357
- ${h}` : h;
358
- const k = this.lexer.state.top;
359
- if (this.lexer.state.top = !0, this.lexer.blockTokens(h, i, !0), this.lexer.state.top = k, t.length === 0)
360
- break;
361
- const p = i.at(-1);
362
- if (p?.type === "code")
363
- break;
364
- if (p?.type === "blockquote") {
365
- const d = p, f = d.raw + `
366
- ` + t.join(`
367
- `), b = this.blockquote(f);
368
- i[i.length - 1] = b, s = s.substring(0, s.length - d.raw.length) + b.raw, r = r.substring(0, r.length - d.text.length) + b.text;
369
- break;
370
- } else if (p?.type === "list") {
371
- const d = p, f = d.raw + `
372
- ` + t.join(`
373
- `), b = this.list(f);
374
- i[i.length - 1] = b, s = s.substring(0, s.length - p.raw.length) + b.raw, r = r.substring(0, r.length - d.raw.length) + b.raw, t = f.substring(i.at(-1).raw.length).split(`
375
- `);
376
- continue;
377
- }
378
- }
379
- return {
380
- type: "blockquote",
381
- raw: s,
382
- tokens: i,
383
- text: r
384
- };
385
- }
386
- }
387
- list(n) {
388
- let e = this.rules.block.list.exec(n);
389
- if (e) {
390
- let t = e[1].trim();
391
- const s = t.length > 1, r = {
392
- type: "list",
393
- raw: "",
394
- ordered: s,
395
- start: s ? +t.slice(0, -1) : "",
396
- loose: !1,
397
- items: []
398
- };
399
- t = s ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = s ? t : "[*+-]");
400
- const i = this.rules.other.listItemRegex(t);
401
- let l = !1;
402
- for (; n; ) {
403
- let c = !1, o = "", h = "";
404
- if (!(e = i.exec(n)) || this.rules.block.hr.test(n))
405
- break;
406
- o = e[0], n = n.substring(o.length);
407
- let k = e[2].split(`
408
- `, 1)[0].replace(this.rules.other.listReplaceTabs, (q) => " ".repeat(3 * q.length)), p = n.split(`
409
- `, 1)[0], d = !k.trim(), f = 0;
410
- if (this.options.pedantic ? (f = 2, h = k.trimStart()) : d ? f = e[1].length + 1 : (f = e[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, h = k.slice(f), f += e[1].length), d && this.rules.other.blankLine.test(p) && (o += p + `
411
- `, n = n.substring(p.length + 1), c = !0), !c) {
412
- const q = this.rules.other.nextBulletRegex(f), K = this.rules.other.hrRegex(f), V = this.rules.other.fencesBeginRegex(f), Y = this.rules.other.headingBeginRegex(f), de = this.rules.other.htmlBeginRegex(f);
413
- for (; n; ) {
414
- const Z = n.split(`
415
- `, 1)[0];
416
- let $;
417
- if (p = Z, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), $ = p) : $ = p.replace(this.rules.other.tabCharGlobal, " "), V.test(p) || Y.test(p) || de.test(p) || q.test(p) || K.test(p))
418
- break;
419
- if ($.search(this.rules.other.nonSpaceChar) >= f || !p.trim())
420
- h += `
421
- ` + $.slice(f);
422
- else {
423
- if (d || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || V.test(k) || Y.test(k) || K.test(k))
424
- break;
425
- h += `
426
- ` + p;
427
- }
428
- !d && !p.trim() && (d = !0), o += Z + `
429
- `, n = n.substring(Z.length + 1), k = $.slice(f);
430
- }
431
- }
432
- r.loose || (l ? r.loose = !0 : this.rules.other.doubleBlankLine.test(o) && (l = !0));
433
- let b = null, J;
434
- this.options.gfm && (b = this.rules.other.listIsTask.exec(h), b && (J = b[0] !== "[ ] ", h = h.replace(this.rules.other.listReplaceTask, ""))), r.items.push({
435
- type: "list_item",
436
- raw: o,
437
- task: !!b,
438
- checked: J,
439
- loose: !1,
440
- text: h,
441
- tokens: []
442
- }), r.raw += o;
443
- }
444
- const a = r.items.at(-1);
445
- if (a)
446
- a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();
447
- else
448
- return;
449
- r.raw = r.raw.trimEnd();
450
- for (let c = 0; c < r.items.length; c++)
451
- if (this.lexer.state.top = !1, r.items[c].tokens = this.lexer.blockTokens(r.items[c].text, []), !r.loose) {
452
- const o = r.items[c].tokens.filter((k) => k.type === "space"), h = o.length > 0 && o.some((k) => this.rules.other.anyLine.test(k.raw));
453
- r.loose = h;
454
- }
455
- if (r.loose)
456
- for (let c = 0; c < r.items.length; c++)
457
- r.items[c].loose = !0;
458
- return r;
459
- }
460
- }
461
- html(n) {
462
- const e = this.rules.block.html.exec(n);
463
- if (e)
464
- return {
465
- type: "html",
466
- block: !0,
467
- raw: e[0],
468
- pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
469
- text: e[0]
470
- };
471
- }
472
- def(n) {
473
- const e = this.rules.block.def.exec(n);
474
- if (e) {
475
- const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
476
- return {
477
- type: "def",
478
- tag: t,
479
- raw: e[0],
480
- href: s,
481
- title: r
482
- };
483
- }
484
- }
485
- table(n) {
486
- const e = this.rules.block.table.exec(n);
487
- if (!e || !this.rules.other.tableDelimiter.test(e[2]))
488
- return;
489
- const t = re(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
490
- `) : [], i = {
491
- type: "table",
492
- raw: e[0],
493
- header: [],
494
- align: [],
495
- rows: []
496
- };
497
- if (t.length === s.length) {
498
- for (const l of s)
499
- this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
500
- for (let l = 0; l < t.length; l++)
501
- i.header.push({
502
- text: t[l],
503
- tokens: this.lexer.inline(t[l]),
504
- header: !0,
505
- align: i.align[l]
506
- });
507
- for (const l of r)
508
- i.rows.push(re(l, i.header.length).map((a, c) => ({
509
- text: a,
510
- tokens: this.lexer.inline(a),
511
- header: !1,
512
- align: i.align[c]
513
- })));
514
- return i;
515
- }
516
- }
517
- lheading(n) {
518
- const e = this.rules.block.lheading.exec(n);
519
- if (e)
520
- return {
521
- type: "heading",
522
- raw: e[0],
523
- depth: e[2].charAt(0) === "=" ? 1 : 2,
524
- text: e[1],
525
- tokens: this.lexer.inline(e[1])
526
- };
527
- }
528
- paragraph(n) {
529
- const e = this.rules.block.paragraph.exec(n);
530
- if (e) {
531
- const t = e[1].charAt(e[1].length - 1) === `
532
- ` ? e[1].slice(0, -1) : e[1];
533
- return {
534
- type: "paragraph",
535
- raw: e[0],
536
- text: t,
537
- tokens: this.lexer.inline(t)
538
- };
539
- }
540
- }
541
- text(n) {
542
- const e = this.rules.block.text.exec(n);
543
- if (e)
544
- return {
545
- type: "text",
546
- raw: e[0],
547
- text: e[0],
548
- tokens: this.lexer.inline(e[0])
549
- };
550
- }
551
- escape(n) {
552
- const e = this.rules.inline.escape.exec(n);
553
- if (e)
554
- return {
555
- type: "escape",
556
- raw: e[0],
557
- text: e[1]
558
- };
559
- }
560
- tag(n) {
561
- const e = this.rules.inline.tag.exec(n);
562
- if (e)
563
- return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
564
- type: "html",
565
- raw: e[0],
566
- inLink: this.lexer.state.inLink,
567
- inRawBlock: this.lexer.state.inRawBlock,
568
- block: !1,
569
- text: e[0]
570
- };
571
- }
572
- link(n) {
573
- const e = this.rules.inline.link.exec(n);
574
- if (e) {
575
- const t = e[2].trim();
576
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
577
- if (!this.rules.other.endAngleBracket.test(t))
578
- return;
579
- const i = v(t.slice(0, -1), "\\");
580
- if ((t.length - i.length) % 2 === 0)
581
- return;
582
- } else {
583
- const i = Ke(e[2], "()");
584
- if (i === -2)
585
- return;
586
- if (i > -1) {
587
- const a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
588
- e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, a).trim(), e[3] = "";
589
- }
590
- }
591
- let s = e[2], r = "";
592
- if (this.options.pedantic) {
593
- const i = this.rules.other.pedanticHrefTitle.exec(s);
594
- i && (s = i[1], r = i[3]);
595
- } else
596
- r = e[3] ? e[3].slice(1, -1) : "";
597
- return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? s = s.slice(1) : s = s.slice(1, -1)), se(e, {
598
- href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
599
- title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
600
- }, e[0], this.lexer, this.rules);
601
- }
602
- }
603
- reflink(n, e) {
604
- let t;
605
- if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
606
- const s = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = e[s.toLowerCase()];
607
- if (!r) {
608
- const i = t[0].charAt(0);
609
- return {
610
- type: "text",
611
- raw: i,
612
- text: i
613
- };
614
- }
615
- return se(t, r, t[0], this.lexer, this.rules);
616
- }
617
- }
618
- emStrong(n, e, t = "") {
619
- let s = this.rules.inline.emStrongLDelim.exec(n);
620
- if (!s || s[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
621
- if (!(s[1] || s[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
622
- const i = [...s[0]].length - 1;
623
- let l, a, c = i, o = 0;
624
- const h = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
625
- for (h.lastIndex = 0, e = e.slice(-1 * n.length + i); (s = h.exec(e)) != null; ) {
626
- if (l = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !l) continue;
627
- if (a = [...l].length, s[3] || s[4]) {
628
- c += a;
629
- continue;
630
- } else if ((s[5] || s[6]) && i % 3 && !((i + a) % 3)) {
631
- o += a;
632
- continue;
633
- }
634
- if (c -= a, c > 0) continue;
635
- a = Math.min(a, a + c + o);
636
- const k = [...s[0]][0].length, p = n.slice(0, i + s.index + k + a);
637
- if (Math.min(i, a) % 2) {
638
- const f = p.slice(1, -1);
639
- return {
640
- type: "em",
641
- raw: p,
642
- text: f,
643
- tokens: this.lexer.inlineTokens(f)
644
- };
645
- }
646
- const d = p.slice(2, -2);
647
- return {
648
- type: "strong",
649
- raw: p,
650
- text: d,
651
- tokens: this.lexer.inlineTokens(d)
652
- };
653
- }
654
- }
655
- }
656
- codespan(n) {
657
- const e = this.rules.inline.code.exec(n);
658
- if (e) {
659
- let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
660
- const s = this.rules.other.nonSpaceChar.test(t), r = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
661
- return s && r && (t = t.substring(1, t.length - 1)), {
662
- type: "codespan",
663
- raw: e[0],
664
- text: t
665
- };
666
- }
667
- }
668
- br(n) {
669
- const e = this.rules.inline.br.exec(n);
670
- if (e)
671
- return {
672
- type: "br",
673
- raw: e[0]
674
- };
675
- }
676
- del(n) {
677
- const e = this.rules.inline.del.exec(n);
678
- if (e)
679
- return {
680
- type: "del",
681
- raw: e[0],
682
- text: e[2],
683
- tokens: this.lexer.inlineTokens(e[2])
684
- };
685
- }
686
- autolink(n) {
687
- const e = this.rules.inline.autolink.exec(n);
688
- if (e) {
689
- let t, s;
690
- return e[2] === "@" ? (t = e[1], s = "mailto:" + t) : (t = e[1], s = t), {
691
- type: "link",
692
- raw: e[0],
693
- text: t,
694
- href: s,
695
- tokens: [
696
- {
697
- type: "text",
698
- raw: t,
699
- text: t
700
- }
701
- ]
702
- };
703
- }
704
- }
705
- url(n) {
706
- let e;
707
- if (e = this.rules.inline.url.exec(n)) {
708
- let t, s;
709
- if (e[2] === "@")
710
- t = e[0], s = "mailto:" + t;
711
- else {
712
- let r;
713
- do
714
- r = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
715
- while (r !== e[0]);
716
- t = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
717
- }
718
- return {
719
- type: "link",
720
- raw: e[0],
721
- text: t,
722
- href: s,
723
- tokens: [
724
- {
725
- type: "text",
726
- raw: t,
727
- text: t
728
- }
729
- ]
730
- };
731
- }
732
- }
733
- inlineText(n) {
734
- const e = this.rules.inline.text.exec(n);
735
- if (e) {
736
- const t = this.lexer.state.inRawBlock;
737
- return {
738
- type: "text",
739
- raw: e[0],
740
- text: e[0],
741
- escaped: t
742
- };
743
- }
744
- }
745
- }, w = class M {
746
- tokens;
747
- options;
748
- state;
749
- tokenizer;
750
- inlineQueue;
751
- constructor(e) {
752
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || S, this.options.tokenizer = this.options.tokenizer || new I(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
753
- inLink: !1,
754
- inRawBlock: !1,
755
- top: !0
756
- };
757
- const t = {
758
- other: x,
759
- block: A.normal,
760
- inline: T.normal
761
- };
762
- this.options.pedantic ? (t.block = A.pedantic, t.inline = T.pedantic) : this.options.gfm && (t.block = A.gfm, this.options.breaks ? t.inline = T.breaks : t.inline = T.gfm), this.tokenizer.rules = t;
763
- }
764
- /**
765
- * Expose Rules
766
- */
767
- static get rules() {
768
- return {
769
- block: A,
770
- inline: T
771
- };
772
- }
773
- /**
774
- * Static Lex Method
775
- */
776
- static lex(e, t) {
777
- return new M(t).lex(e);
778
- }
779
- /**
780
- * Static Lex Inline Method
781
- */
782
- static lexInline(e, t) {
783
- return new M(t).inlineTokens(e);
784
- }
785
- /**
786
- * Preprocessing
787
- */
788
- lex(e) {
789
- e = e.replace(x.carriageReturn, `
790
- `), this.blockTokens(e, this.tokens);
791
- for (let t = 0; t < this.inlineQueue.length; t++) {
792
- const s = this.inlineQueue[t];
793
- this.inlineTokens(s.src, s.tokens);
794
- }
795
- return this.inlineQueue = [], this.tokens;
796
- }
797
- blockTokens(e, t = [], s = !1) {
798
- for (this.options.pedantic && (e = e.replace(x.tabCharGlobal, " ").replace(x.spaceLine, "")); e; ) {
799
- let r;
800
- if (this.options.extensions?.block?.some((l) => (r = l.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1))
801
- continue;
802
- if (r = this.tokenizer.space(e)) {
803
- e = e.substring(r.raw.length);
804
- const l = t.at(-1);
805
- r.raw.length === 1 && l !== void 0 ? l.raw += `
806
- ` : t.push(r);
807
- continue;
808
- }
809
- if (r = this.tokenizer.code(e)) {
810
- e = e.substring(r.raw.length);
811
- const l = t.at(-1);
812
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += `
813
- ` + r.raw, l.text += `
814
- ` + r.text, this.inlineQueue.at(-1).src = l.text) : t.push(r);
815
- continue;
816
- }
817
- if (r = this.tokenizer.fences(e)) {
818
- e = e.substring(r.raw.length), t.push(r);
819
- continue;
820
- }
821
- if (r = this.tokenizer.heading(e)) {
822
- e = e.substring(r.raw.length), t.push(r);
823
- continue;
824
- }
825
- if (r = this.tokenizer.hr(e)) {
826
- e = e.substring(r.raw.length), t.push(r);
827
- continue;
828
- }
829
- if (r = this.tokenizer.blockquote(e)) {
830
- e = e.substring(r.raw.length), t.push(r);
831
- continue;
832
- }
833
- if (r = this.tokenizer.list(e)) {
834
- e = e.substring(r.raw.length), t.push(r);
835
- continue;
836
- }
837
- if (r = this.tokenizer.html(e)) {
838
- e = e.substring(r.raw.length), t.push(r);
839
- continue;
840
- }
841
- if (r = this.tokenizer.def(e)) {
842
- e = e.substring(r.raw.length);
843
- const l = t.at(-1);
844
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += `
845
- ` + r.raw, l.text += `
846
- ` + r.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
847
- href: r.href,
848
- title: r.title
849
- });
850
- continue;
851
- }
852
- if (r = this.tokenizer.table(e)) {
853
- e = e.substring(r.raw.length), t.push(r);
854
- continue;
855
- }
856
- if (r = this.tokenizer.lheading(e)) {
857
- e = e.substring(r.raw.length), t.push(r);
858
- continue;
859
- }
860
- let i = e;
861
- if (this.options.extensions?.startBlock) {
862
- let l = 1 / 0;
863
- const a = e.slice(1);
864
- let c;
865
- this.options.extensions.startBlock.forEach((o) => {
866
- c = o.call({ lexer: this }, a), typeof c == "number" && c >= 0 && (l = Math.min(l, c));
867
- }), l < 1 / 0 && l >= 0 && (i = e.substring(0, l + 1));
868
- }
869
- if (this.state.top && (r = this.tokenizer.paragraph(i))) {
870
- const l = t.at(-1);
871
- s && l?.type === "paragraph" ? (l.raw += `
872
- ` + r.raw, l.text += `
873
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(r), s = i.length !== e.length, e = e.substring(r.raw.length);
874
- continue;
875
- }
876
- if (r = this.tokenizer.text(e)) {
877
- e = e.substring(r.raw.length);
878
- const l = t.at(-1);
879
- l?.type === "text" ? (l.raw += `
880
- ` + r.raw, l.text += `
881
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(r);
882
- continue;
883
- }
884
- if (e) {
885
- const l = "Infinite loop on byte: " + e.charCodeAt(0);
886
- if (this.options.silent) {
887
- console.error(l);
888
- break;
889
- } else
890
- throw new Error(l);
891
- }
892
- }
893
- return this.state.top = !0, t;
894
- }
895
- inline(e, t = []) {
896
- return this.inlineQueue.push({ src: e, tokens: t }), t;
897
- }
898
- /**
899
- * Lexing/Compiling
900
- */
901
- inlineTokens(e, t = []) {
902
- let s = e, r = null;
903
- if (this.tokens.links) {
904
- const a = Object.keys(this.tokens.links);
905
- if (a.length > 0)
906
- for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; )
907
- a.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
908
- }
909
- for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; )
910
- s = s.slice(0, r.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
911
- for (; (r = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; )
912
- s = s.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
913
- let i = !1, l = "";
914
- for (; e; ) {
915
- i || (l = ""), i = !1;
916
- let a;
917
- if (this.options.extensions?.inline?.some((o) => (a = o.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), !0) : !1))
918
- continue;
919
- if (a = this.tokenizer.escape(e)) {
920
- e = e.substring(a.raw.length), t.push(a);
921
- continue;
922
- }
923
- if (a = this.tokenizer.tag(e)) {
924
- e = e.substring(a.raw.length), t.push(a);
925
- continue;
926
- }
927
- if (a = this.tokenizer.link(e)) {
928
- e = e.substring(a.raw.length), t.push(a);
929
- continue;
930
- }
931
- if (a = this.tokenizer.reflink(e, this.tokens.links)) {
932
- e = e.substring(a.raw.length);
933
- const o = t.at(-1);
934
- a.type === "text" && o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : t.push(a);
935
- continue;
936
- }
937
- if (a = this.tokenizer.emStrong(e, s, l)) {
938
- e = e.substring(a.raw.length), t.push(a);
939
- continue;
940
- }
941
- if (a = this.tokenizer.codespan(e)) {
942
- e = e.substring(a.raw.length), t.push(a);
943
- continue;
944
- }
945
- if (a = this.tokenizer.br(e)) {
946
- e = e.substring(a.raw.length), t.push(a);
947
- continue;
948
- }
949
- if (a = this.tokenizer.del(e)) {
950
- e = e.substring(a.raw.length), t.push(a);
951
- continue;
952
- }
953
- if (a = this.tokenizer.autolink(e)) {
954
- e = e.substring(a.raw.length), t.push(a);
955
- continue;
956
- }
957
- if (!this.state.inLink && (a = this.tokenizer.url(e))) {
958
- e = e.substring(a.raw.length), t.push(a);
959
- continue;
960
- }
961
- let c = e;
962
- if (this.options.extensions?.startInline) {
963
- let o = 1 / 0;
964
- const h = e.slice(1);
965
- let k;
966
- this.options.extensions.startInline.forEach((p) => {
967
- k = p.call({ lexer: this }, h), typeof k == "number" && k >= 0 && (o = Math.min(o, k));
968
- }), o < 1 / 0 && o >= 0 && (c = e.substring(0, o + 1));
969
- }
970
- if (a = this.tokenizer.inlineText(c)) {
971
- e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (l = a.raw.slice(-1)), i = !0;
972
- const o = t.at(-1);
973
- o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : t.push(a);
974
- continue;
975
- }
976
- if (e) {
977
- const o = "Infinite loop on byte: " + e.charCodeAt(0);
978
- if (this.options.silent) {
979
- console.error(o);
980
- break;
981
- } else
982
- throw new Error(o);
983
- }
984
- }
985
- return t;
986
- }
987
- }, P = class {
988
- options;
989
- parser;
990
- // set by the parser
991
- constructor(n) {
992
- this.options = n || S;
993
- }
994
- space(n) {
995
- return "";
996
- }
997
- code({ text: n, lang: e, escaped: t }) {
998
- const s = (e || "").match(x.notSpaceStart)?.[0], r = n.replace(x.endingNewline, "") + `
999
- `;
1000
- return s ? '<pre><code class="language-' + m(s) + '">' + (t ? r : m(r, !0)) + `</code></pre>
1001
- ` : "<pre><code>" + (t ? r : m(r, !0)) + `</code></pre>
1002
- `;
1003
- }
1004
- blockquote({ tokens: n }) {
1005
- return `<blockquote>
1006
- ${this.parser.parse(n)}</blockquote>
1007
- `;
1008
- }
1009
- html({ text: n }) {
1010
- return n;
1011
- }
1012
- heading({ tokens: n, depth: e }) {
1013
- return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1014
- `;
1015
- }
1016
- hr(n) {
1017
- return `<hr>
1018
- `;
1019
- }
1020
- list(n) {
1021
- const e = n.ordered, t = n.start;
1022
- let s = "";
1023
- for (let l = 0; l < n.items.length; l++) {
1024
- const a = n.items[l];
1025
- s += this.listitem(a);
1026
- }
1027
- const r = e ? "ol" : "ul", i = e && t !== 1 ? ' start="' + t + '"' : "";
1028
- return "<" + r + i + `>
1029
- ` + s + "</" + r + `>
1030
- `;
1031
- }
1032
- listitem(n) {
1033
- let e = "";
1034
- if (n.task) {
1035
- const t = this.checkbox({ checked: !!n.checked });
1036
- n.loose ? n.tokens[0]?.type === "paragraph" ? (n.tokens[0].text = t + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = t + " " + m(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1037
- type: "text",
1038
- raw: t + " ",
1039
- text: t + " ",
1040
- escaped: !0
1041
- }) : e += t + " ";
1042
- }
1043
- return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1044
- `;
1045
- }
1046
- checkbox({ checked: n }) {
1047
- return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1048
- }
1049
- paragraph({ tokens: n }) {
1050
- return `<p>${this.parser.parseInline(n)}</p>
1051
- `;
1052
- }
1053
- table(n) {
1054
- let e = "", t = "";
1055
- for (let r = 0; r < n.header.length; r++)
1056
- t += this.tablecell(n.header[r]);
1057
- e += this.tablerow({ text: t });
1058
- let s = "";
1059
- for (let r = 0; r < n.rows.length; r++) {
1060
- const i = n.rows[r];
1061
- t = "";
1062
- for (let l = 0; l < i.length; l++)
1063
- t += this.tablecell(i[l]);
1064
- s += this.tablerow({ text: t });
1065
- }
1066
- return s && (s = `<tbody>${s}</tbody>`), `<table>
1067
- <thead>
1068
- ` + e + `</thead>
1069
- ` + s + `</table>
1070
- `;
1071
- }
1072
- tablerow({ text: n }) {
1073
- return `<tr>
1074
- ${n}</tr>
1075
- `;
1076
- }
1077
- tablecell(n) {
1078
- const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1079
- return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1080
- `;
1081
- }
1082
- /**
1083
- * span level renderer
1084
- */
1085
- strong({ tokens: n }) {
1086
- return `<strong>${this.parser.parseInline(n)}</strong>`;
1087
- }
1088
- em({ tokens: n }) {
1089
- return `<em>${this.parser.parseInline(n)}</em>`;
1090
- }
1091
- codespan({ text: n }) {
1092
- return `<code>${m(n, !0)}</code>`;
1093
- }
1094
- br(n) {
1095
- return "<br>";
1096
- }
1097
- del({ tokens: n }) {
1098
- return `<del>${this.parser.parseInline(n)}</del>`;
1099
- }
1100
- link({ href: n, title: e, tokens: t }) {
1101
- const s = this.parser.parseInline(t), r = ne(n);
1102
- if (r === null)
1103
- return s;
1104
- n = r;
1105
- let i = '<a href="' + n + '"';
1106
- return e && (i += ' title="' + m(e) + '"'), i += ">" + s + "</a>", i;
1107
- }
1108
- image({ href: n, title: e, text: t, tokens: s }) {
1109
- s && (t = this.parser.parseInline(s, this.parser.textRenderer));
1110
- const r = ne(n);
1111
- if (r === null)
1112
- return m(t);
1113
- n = r;
1114
- let i = `<img src="${n}" alt="${t}"`;
1115
- return e && (i += ` title="${m(e)}"`), i += ">", i;
1116
- }
1117
- text(n) {
1118
- return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : m(n.text);
1119
- }
1120
- }, W = class {
1121
- // no need for block level renderers
1122
- strong({ text: n }) {
1123
- return n;
1124
- }
1125
- em({ text: n }) {
1126
- return n;
1127
- }
1128
- codespan({ text: n }) {
1129
- return n;
1130
- }
1131
- del({ text: n }) {
1132
- return n;
1133
- }
1134
- html({ text: n }) {
1135
- return n;
1136
- }
1137
- text({ text: n }) {
1138
- return n;
1139
- }
1140
- link({ text: n }) {
1141
- return "" + n;
1142
- }
1143
- image({ text: n }) {
1144
- return "" + n;
1145
- }
1146
- br() {
1147
- return "";
1148
- }
1149
- }, y = class G {
1150
- options;
1151
- renderer;
1152
- textRenderer;
1153
- constructor(e) {
1154
- this.options = e || S, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new W();
1155
- }
1156
- /**
1157
- * Static Parse Method
1158
- */
1159
- static parse(e, t) {
1160
- return new G(t).parse(e);
1161
- }
1162
- /**
1163
- * Static Parse Inline Method
1164
- */
1165
- static parseInline(e, t) {
1166
- return new G(t).parseInline(e);
1167
- }
1168
- /**
1169
- * Parse Loop
1170
- */
1171
- parse(e, t = !0) {
1172
- let s = "";
1173
- for (let r = 0; r < e.length; r++) {
1174
- const i = e[r];
1175
- if (this.options.extensions?.renderers?.[i.type]) {
1176
- const a = i, c = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1177
- if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
1178
- s += c || "";
1179
- continue;
1180
- }
1181
- }
1182
- const l = i;
1183
- switch (l.type) {
1184
- case "space": {
1185
- s += this.renderer.space(l);
1186
- continue;
1187
- }
1188
- case "hr": {
1189
- s += this.renderer.hr(l);
1190
- continue;
1191
- }
1192
- case "heading": {
1193
- s += this.renderer.heading(l);
1194
- continue;
1195
- }
1196
- case "code": {
1197
- s += this.renderer.code(l);
1198
- continue;
1199
- }
1200
- case "table": {
1201
- s += this.renderer.table(l);
1202
- continue;
1203
- }
1204
- case "blockquote": {
1205
- s += this.renderer.blockquote(l);
1206
- continue;
1207
- }
1208
- case "list": {
1209
- s += this.renderer.list(l);
1210
- continue;
1211
- }
1212
- case "html": {
1213
- s += this.renderer.html(l);
1214
- continue;
1215
- }
1216
- case "paragraph": {
1217
- s += this.renderer.paragraph(l);
1218
- continue;
1219
- }
1220
- case "text": {
1221
- let a = l, c = this.renderer.text(a);
1222
- for (; r + 1 < e.length && e[r + 1].type === "text"; )
1223
- a = e[++r], c += `
1224
- ` + this.renderer.text(a);
1225
- t ? s += this.renderer.paragraph({
1226
- type: "paragraph",
1227
- raw: c,
1228
- text: c,
1229
- tokens: [{ type: "text", raw: c, text: c, escaped: !0 }]
1230
- }) : s += c;
1231
- continue;
1232
- }
1233
- default: {
1234
- const a = 'Token with "' + l.type + '" type was not found.';
1235
- if (this.options.silent)
1236
- return console.error(a), "";
1237
- throw new Error(a);
1238
- }
1239
- }
1240
- }
1241
- return s;
1242
- }
1243
- /**
1244
- * Parse Inline Tokens
1245
- */
1246
- parseInline(e, t = this.renderer) {
1247
- let s = "";
1248
- for (let r = 0; r < e.length; r++) {
1249
- const i = e[r];
1250
- if (this.options.extensions?.renderers?.[i.type]) {
1251
- const a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1252
- if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
1253
- s += a || "";
1254
- continue;
1255
- }
1256
- }
1257
- const l = i;
1258
- switch (l.type) {
1259
- case "escape": {
1260
- s += t.text(l);
1261
- break;
1262
- }
1263
- case "html": {
1264
- s += t.html(l);
1265
- break;
1266
- }
1267
- case "link": {
1268
- s += t.link(l);
1269
- break;
1270
- }
1271
- case "image": {
1272
- s += t.image(l);
1273
- break;
1274
- }
1275
- case "strong": {
1276
- s += t.strong(l);
1277
- break;
1278
- }
1279
- case "em": {
1280
- s += t.em(l);
1281
- break;
1282
- }
1283
- case "codespan": {
1284
- s += t.codespan(l);
1285
- break;
1286
- }
1287
- case "br": {
1288
- s += t.br(l);
1289
- break;
1290
- }
1291
- case "del": {
1292
- s += t.del(l);
1293
- break;
1294
- }
1295
- case "text": {
1296
- s += t.text(l);
1297
- break;
1298
- }
1299
- default: {
1300
- const a = 'Token with "' + l.type + '" type was not found.';
1301
- if (this.options.silent)
1302
- return console.error(a), "";
1303
- throw new Error(a);
1304
- }
1305
- }
1306
- }
1307
- return s;
1308
- }
1309
- }, L = class {
1310
- options;
1311
- block;
1312
- constructor(n) {
1313
- this.options = n || S;
1314
- }
1315
- static passThroughHooks = /* @__PURE__ */ new Set([
1316
- "preprocess",
1317
- "postprocess",
1318
- "processAllTokens"
1319
- ]);
1320
- /**
1321
- * Process markdown before marked
1322
- */
1323
- preprocess(n) {
1324
- return n;
1325
- }
1326
- /**
1327
- * Process HTML after marked is finished
1328
- */
1329
- postprocess(n) {
1330
- return n;
1331
- }
1332
- /**
1333
- * Process all tokens before walk tokens
1334
- */
1335
- processAllTokens(n) {
1336
- return n;
1337
- }
1338
- /**
1339
- * Provide function to tokenize markdown
1340
- */
1341
- provideLexer() {
1342
- return this.block ? w.lex : w.lexInline;
1343
- }
1344
- /**
1345
- * Provide function to parse tokens
1346
- */
1347
- provideParser() {
1348
- return this.block ? y.parse : y.parseInline;
1349
- }
1350
- }, Ye = class {
1351
- defaults = O();
1352
- options = this.setOptions;
1353
- parse = this.parseMarkdown(!0);
1354
- parseInline = this.parseMarkdown(!1);
1355
- Parser = y;
1356
- Renderer = P;
1357
- TextRenderer = W;
1358
- Lexer = w;
1359
- Tokenizer = I;
1360
- Hooks = L;
1361
- constructor(...n) {
1362
- this.use(...n);
1363
- }
1364
- /**
1365
- * Run callback for every token
1366
- */
1367
- walkTokens(n, e) {
1368
- let t = [];
1369
- for (const s of n)
1370
- switch (t = t.concat(e.call(this, s)), s.type) {
1371
- case "table": {
1372
- const r = s;
1373
- for (const i of r.header)
1374
- t = t.concat(this.walkTokens(i.tokens, e));
1375
- for (const i of r.rows)
1376
- for (const l of i)
1377
- t = t.concat(this.walkTokens(l.tokens, e));
1378
- break;
1379
- }
1380
- case "list": {
1381
- const r = s;
1382
- t = t.concat(this.walkTokens(r.items, e));
1383
- break;
1384
- }
1385
- default: {
1386
- const r = s;
1387
- this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1388
- const l = r[i].flat(1 / 0);
1389
- t = t.concat(this.walkTokens(l, e));
1390
- }) : r.tokens && (t = t.concat(this.walkTokens(r.tokens, e)));
1391
- }
1392
- }
1393
- return t;
1394
- }
1395
- use(...n) {
1396
- const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1397
- return n.forEach((t) => {
1398
- const s = { ...t };
1399
- if (s.async = this.defaults.async || s.async || !1, t.extensions && (t.extensions.forEach((r) => {
1400
- if (!r.name)
1401
- throw new Error("extension name required");
1402
- if ("renderer" in r) {
1403
- const i = e.renderers[r.name];
1404
- i ? e.renderers[r.name] = function(...l) {
1405
- let a = r.renderer.apply(this, l);
1406
- return a === !1 && (a = i.apply(this, l)), a;
1407
- } : e.renderers[r.name] = r.renderer;
1408
- }
1409
- if ("tokenizer" in r) {
1410
- if (!r.level || r.level !== "block" && r.level !== "inline")
1411
- throw new Error("extension level must be 'block' or 'inline'");
1412
- const i = e[r.level];
1413
- i ? i.unshift(r.tokenizer) : e[r.level] = [r.tokenizer], r.start && (r.level === "block" ? e.startBlock ? e.startBlock.push(r.start) : e.startBlock = [r.start] : r.level === "inline" && (e.startInline ? e.startInline.push(r.start) : e.startInline = [r.start]));
1414
- }
1415
- "childTokens" in r && r.childTokens && (e.childTokens[r.name] = r.childTokens);
1416
- }), s.extensions = e), t.renderer) {
1417
- const r = this.defaults.renderer || new P(this.defaults);
1418
- for (const i in t.renderer) {
1419
- if (!(i in r))
1420
- throw new Error(`renderer '${i}' does not exist`);
1421
- if (["options", "parser"].includes(i))
1422
- continue;
1423
- const l = i, a = t.renderer[l], c = r[l];
1424
- r[l] = (...o) => {
1425
- let h = a.apply(r, o);
1426
- return h === !1 && (h = c.apply(r, o)), h || "";
1427
- };
1428
- }
1429
- s.renderer = r;
1430
- }
1431
- if (t.tokenizer) {
1432
- const r = this.defaults.tokenizer || new I(this.defaults);
1433
- for (const i in t.tokenizer) {
1434
- if (!(i in r))
1435
- throw new Error(`tokenizer '${i}' does not exist`);
1436
- if (["options", "rules", "lexer"].includes(i))
1437
- continue;
1438
- const l = i, a = t.tokenizer[l], c = r[l];
1439
- r[l] = (...o) => {
1440
- let h = a.apply(r, o);
1441
- return h === !1 && (h = c.apply(r, o)), h;
1442
- };
1443
- }
1444
- s.tokenizer = r;
1445
- }
1446
- if (t.hooks) {
1447
- const r = this.defaults.hooks || new L();
1448
- for (const i in t.hooks) {
1449
- if (!(i in r))
1450
- throw new Error(`hook '${i}' does not exist`);
1451
- if (["options", "block"].includes(i))
1452
- continue;
1453
- const l = i, a = t.hooks[l], c = r[l];
1454
- L.passThroughHooks.has(i) ? r[l] = (o) => {
1455
- if (this.defaults.async)
1456
- return Promise.resolve(a.call(r, o)).then((k) => c.call(r, k));
1457
- const h = a.call(r, o);
1458
- return c.call(r, h);
1459
- } : r[l] = (...o) => {
1460
- let h = a.apply(r, o);
1461
- return h === !1 && (h = c.apply(r, o)), h;
1462
- };
1463
- }
1464
- s.hooks = r;
1465
- }
1466
- if (t.walkTokens) {
1467
- const r = this.defaults.walkTokens, i = t.walkTokens;
1468
- s.walkTokens = function(l) {
1469
- let a = [];
1470
- return a.push(i.call(this, l)), r && (a = a.concat(r.call(this, l))), a;
1471
- };
1472
- }
1473
- this.defaults = { ...this.defaults, ...s };
1474
- }), this;
1475
- }
1476
- setOptions(n) {
1477
- return this.defaults = { ...this.defaults, ...n }, this;
1478
- }
1479
- lexer(n, e) {
1480
- return w.lex(n, e ?? this.defaults);
1481
- }
1482
- parser(n, e) {
1483
- return y.parse(n, e ?? this.defaults);
1484
- }
1485
- parseMarkdown(n) {
1486
- return (t, s) => {
1487
- const r = { ...s }, i = { ...this.defaults, ...r }, l = this.onError(!!i.silent, !!i.async);
1488
- if (this.defaults.async === !0 && r.async === !1)
1489
- return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1490
- if (typeof t > "u" || t === null)
1491
- return l(new Error("marked(): input parameter is undefined or null"));
1492
- if (typeof t != "string")
1493
- return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1494
- i.hooks && (i.hooks.options = i, i.hooks.block = n);
1495
- const a = i.hooks ? i.hooks.provideLexer() : n ? w.lex : w.lexInline, c = i.hooks ? i.hooks.provideParser() : n ? y.parse : y.parseInline;
1496
- if (i.async)
1497
- return Promise.resolve(i.hooks ? i.hooks.preprocess(t) : t).then((o) => a(o, i)).then((o) => i.hooks ? i.hooks.processAllTokens(o) : o).then((o) => i.walkTokens ? Promise.all(this.walkTokens(o, i.walkTokens)).then(() => o) : o).then((o) => c(o, i)).then((o) => i.hooks ? i.hooks.postprocess(o) : o).catch(l);
1498
- try {
1499
- i.hooks && (t = i.hooks.preprocess(t));
1500
- let o = a(t, i);
1501
- i.hooks && (o = i.hooks.processAllTokens(o)), i.walkTokens && this.walkTokens(o, i.walkTokens);
1502
- let h = c(o, i);
1503
- return i.hooks && (h = i.hooks.postprocess(h)), h;
1504
- } catch (o) {
1505
- return l(o);
1506
- }
1507
- };
1508
- }
1509
- onError(n, e) {
1510
- return (t) => {
1511
- if (t.message += `
1512
- Please report this to https://github.com/markedjs/marked.`, n) {
1513
- const s = "<p>An error occurred:</p><pre>" + m(t.message + "", !0) + "</pre>";
1514
- return e ? Promise.resolve(s) : s;
1515
- }
1516
- if (e)
1517
- return Promise.reject(t);
1518
- throw t;
1519
- };
1520
- }
1521
- }, R = new Ye();
1522
- function g(n, e) {
1523
- return R.parse(n, e);
1524
- }
1525
- g.options = g.setOptions = function(n) {
1526
- return R.setOptions(n), g.defaults = R.defaults, ie(g.defaults), g;
1527
- };
1528
- g.getDefaults = O;
1529
- g.defaults = S;
1530
- g.use = function(...n) {
1531
- return R.use(...n), g.defaults = R.defaults, ie(g.defaults), g;
1532
- };
1533
- g.walkTokens = function(n, e) {
1534
- return R.walkTokens(n, e);
1535
- };
1536
- g.parseInline = R.parseInline;
1537
- g.Parser = y;
1538
- g.parser = y.parse;
1539
- g.Renderer = P;
1540
- g.TextRenderer = W;
1541
- g.Lexer = w;
1542
- g.lexer = w.lex;
1543
- g.Tokenizer = I;
1544
- g.Hooks = L;
1545
- g.parse = g;
1546
- g.options;
1547
- g.setOptions;
1548
- g.use;
1549
- g.walkTokens;
1550
- g.parseInline;
1551
- y.parse;
1552
- w.lex;
1553
- const tt = (n) => xe.sanitize(g.parse(n, { async: !1 }));
1554
- export {
1555
- g as a,
1556
- tt as m
1557
- };