@prokodo/ui 0.1.5 → 0.1.7

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 (51) hide show
  1. package/dist/components/accordion/Accordion.css +8 -4
  2. package/dist/components/accordion/Accordion.module.css +8 -4
  3. package/dist/components/button/Button.css +1 -3
  4. package/dist/components/button/Button.module.css +1 -3
  5. package/dist/components/card/Card.css +1 -4
  6. package/dist/components/card/Card.module.css +1 -4
  7. package/dist/components/chip/Chip.css +1 -2
  8. package/dist/components/chip/Chip.module.css +1 -2
  9. package/dist/components/drawer/Drawer.view.js +2 -1
  10. package/dist/components/form/Form.view.js +2 -2
  11. package/dist/components/image-text/ImageText.css +1 -3
  12. package/dist/components/image-text/ImageText.module.css +1 -3
  13. package/dist/components/input/Input.css +49 -6
  14. package/dist/components/input/Input.module.css +49 -6
  15. package/dist/components/input/Input.view.js +1 -1
  16. package/dist/components/list/List.css +2 -6
  17. package/dist/components/list/List.module.css +2 -6
  18. package/dist/components/lottie/Lottie.js +0 -1
  19. package/dist/components/post-item/PostItem.css +3 -9
  20. package/dist/components/post-item/PostItem.module.css +3 -9
  21. package/dist/components/post-teaser/PostTeaser.css +1 -3
  22. package/dist/components/post-teaser/PostTeaser.module.css +1 -3
  23. package/dist/components/quote/Quote.css +1 -3
  24. package/dist/components/quote/Quote.module.css +1 -3
  25. package/dist/components/rich-text/RichText.client.js +4 -4
  26. package/dist/components/rich-text/RichText.css +1 -3
  27. package/dist/components/rich-text/RichText.module.css +1 -3
  28. package/dist/components/select/Select.css +3 -9
  29. package/dist/components/select/Select.module.css +3 -9
  30. package/dist/components/sidenav/SideNav.css +1 -3
  31. package/dist/components/sidenav/SideNav.module.css +1 -3
  32. package/dist/components/slider/Slider.css +1 -3
  33. package/dist/components/slider/Slider.module.css +1 -3
  34. package/dist/components/snackbar/Snackbar.css +1 -1
  35. package/dist/components/snackbar/Snackbar.module.css +1 -1
  36. package/dist/components/table/Table.css +1 -3
  37. package/dist/components/table/Table.module.css +1 -3
  38. package/dist/components/teaser/Teaser.css +1 -3
  39. package/dist/components/teaser/Teaser.module.css +1 -3
  40. package/dist/constants/project.js +1 -1
  41. package/dist/hooks/useGoogleMaps.js +15 -12
  42. package/dist/node_modules/.pnpm/marked@17.0.1/node_modules/marked/lib/marked.esm.js +1150 -0
  43. package/dist/theme.css +78 -69
  44. package/dist/tsconfig.build.tsbuildinfo +1 -1
  45. package/dist/types/components/drawer/Drawer.model.d.ts +1 -0
  46. package/dist/types/components/image/Image.d.ts +1 -0
  47. package/dist/types/components/image/Image.lazy.d.ts +1 -0
  48. package/dist/types/components/lottie/Lottie.model.d.ts +2 -2
  49. package/package.json +10 -10
  50. package/dist/node_modules/.pnpm/marked@15.0.12/node_modules/marked/lib/marked.esm.js +0 -2169
  51. /package/dist/node_modules/.pnpm/{marked-highlight@2.2.2_marked@15.0.12 → marked-highlight@2.2.3_marked@17.0.1}/node_modules/marked-highlight/src/index.js +0 -0
@@ -1,2169 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- var _a, _b, _c, _d, _e, _f, _g;
6
- function _getDefaults() {
7
- return {
8
- async: false,
9
- breaks: false,
10
- extensions: null,
11
- gfm: true,
12
- hooks: null,
13
- pedantic: false,
14
- renderer: null,
15
- silent: false,
16
- tokenizer: null,
17
- walkTokens: null
18
- };
19
- }
20
- __name(_getDefaults, "_getDefaults");
21
- var _defaults = _getDefaults();
22
- function changeDefaults(newDefaults) {
23
- _defaults = newDefaults;
24
- }
25
- __name(changeDefaults, "changeDefaults");
26
- var noopTest = { exec: /* @__PURE__ */ __name(() => null, "exec") };
27
- function edit(regex, opt = "") {
28
- let source = typeof regex === "string" ? regex : regex.source;
29
- const obj = {
30
- replace: /* @__PURE__ */ __name((name, val) => {
31
- let valSource = typeof val === "string" ? val : val.source;
32
- valSource = valSource.replace(other.caret, "$1");
33
- source = source.replace(name, valSource);
34
- return obj;
35
- }, "replace"),
36
- getRegex: /* @__PURE__ */ __name(() => {
37
- return new RegExp(source, opt);
38
- }, "getRegex")
39
- };
40
- return obj;
41
- }
42
- __name(edit, "edit");
43
- var other = {
44
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
45
- outputLinkReplace: /\\([\[\]])/g,
46
- indentCodeCompensation: /^(\s+)(?:```)/,
47
- beginningSpace: /^\s+/,
48
- endingHash: /#$/,
49
- startingSpaceChar: /^ /,
50
- endingSpaceChar: / $/,
51
- nonSpaceChar: /[^ ]/,
52
- newLineCharGlobal: /\n/g,
53
- tabCharGlobal: /\t/g,
54
- multipleSpaceGlobal: /\s+/g,
55
- blankLine: /^[ \t]*$/,
56
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
57
- blockquoteStart: /^ {0,3}>/,
58
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
59
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
60
- listReplaceTabs: /^\t+/,
61
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
62
- listIsTask: /^\[[ xX]\] /,
63
- listReplaceTask: /^\[[ xX]\] +/,
64
- anyLine: /\n.*\n/,
65
- hrefBrackets: /^<(.*)>$/,
66
- tableDelimiter: /[:|]/,
67
- tableAlignChars: /^\||\| *$/g,
68
- tableRowBlankLine: /\n[ \t]*$/,
69
- tableAlignRight: /^ *-+: *$/,
70
- tableAlignCenter: /^ *:-+: *$/,
71
- tableAlignLeft: /^ *:-+ *$/,
72
- startATag: /^<a /i,
73
- endATag: /^<\/a>/i,
74
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
75
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
76
- startAngleBracket: /^</,
77
- endAngleBracket: />$/,
78
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
79
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
80
- escapeTest: /[&<>"']/,
81
- escapeReplace: /[&<>"']/g,
82
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
83
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
84
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
85
- caret: /(^|[^\[])\^/g,
86
- percentDecode: /%25/g,
87
- findPipe: /\|/g,
88
- splitPipe: / \|/,
89
- slashPipe: /\\\|/g,
90
- carriageReturn: /\r\n|\r/g,
91
- spaceLine: /^ +$/gm,
92
- notSpaceStart: /^\S*/,
93
- endingNewline: /\n$/,
94
- listItemRegex: /* @__PURE__ */ __name((bull) => new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`), "listItemRegex"),
95
- nextBulletRegex: /* @__PURE__ */ __name((indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), "nextBulletRegex"),
96
- hrRegex: /* @__PURE__ */ __name((indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), "hrRegex"),
97
- fencesBeginRegex: /* @__PURE__ */ __name((indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`), "fencesBeginRegex"),
98
- headingBeginRegex: /* @__PURE__ */ __name((indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`), "headingBeginRegex"),
99
- htmlBeginRegex: /* @__PURE__ */ __name((indent) => new RegExp(`^ {0,${Math.min(3, indent - 1)}}<(?:[a-z].*>|!--)`, "i"), "htmlBeginRegex")
100
- };
101
- var newline = /^(?:[ \t]*(?:\n|$))+/;
102
- var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
103
- var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
104
- var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
105
- var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
106
- var bullet = /(?:[*+-]|\d{1,9}[.)])/;
107
- var lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
108
- var lheading = edit(lheadingCore).replace(/bull/g, bullet).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();
109
- var lheadingGfm = edit(lheadingCore).replace(/bull/g, bullet).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();
110
- var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
111
- var blockText = /^[^\n]+/;
112
- var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
113
- var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
114
- var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
115
- var _tag = "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";
116
- var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
117
- var html = edit(
118
- "^ {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|$))",
119
- "i"
120
- ).replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
121
- var paragraph = edit(_paragraph).replace("hr", 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", _tag).getRegex();
122
- var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
123
- var blockNormal = {
124
- blockquote,
125
- code: blockCode,
126
- def,
127
- fences,
128
- heading,
129
- hr,
130
- html,
131
- lheading,
132
- list,
133
- newline,
134
- paragraph,
135
- table: noopTest,
136
- text: blockText
137
- };
138
- var gfmTable = edit(
139
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
140
- ).replace("hr", 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", _tag).getRegex();
141
- var blockGfm = {
142
- ...blockNormal,
143
- lheading: lheadingGfm,
144
- table: gfmTable,
145
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).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", _tag).getRegex()
146
- };
147
- var blockPedantic = {
148
- ...blockNormal,
149
- html: edit(
150
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
151
- ).replace("comment", _comment).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(),
152
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
153
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
154
- fences: noopTest,
155
- // fences not supported
156
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
157
- paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
158
- };
159
- var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
160
- var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
161
- var br = /^( {2,}|\\)\n(?!\s*$)/;
162
- var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
163
- var _punctuation = /[\p{P}\p{S}]/u;
164
- var _punctuationOrSpace = /[\s\p{P}\p{S}]/u;
165
- var _notPunctuationOrSpace = /[^\s\p{P}\p{S}]/u;
166
- var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
167
- var _punctuationGfmStrongEm = /(?!~)[\p{P}\p{S}]/u;
168
- var _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
169
- var _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
170
- var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
171
- var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
172
- var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
173
- var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
174
- var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
175
- var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
176
- var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
177
- var emStrongRDelimUnd = edit(
178
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
179
- "gu"
180
- ).replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
181
- var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
182
- var autolink = edit(/^<(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();
183
- var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
184
- var tag = edit(
185
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
186
- ).replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
187
- var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
188
- var link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
189
- var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
190
- var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
191
- var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
192
- var inlineNormal = {
193
- _backpedal: noopTest,
194
- // only used for GFM url
195
- anyPunctuation,
196
- autolink,
197
- blockSkip,
198
- br,
199
- code: inlineCode,
200
- del: noopTest,
201
- emStrongLDelim,
202
- emStrongRDelimAst,
203
- emStrongRDelimUnd,
204
- escape,
205
- link,
206
- nolink,
207
- punctuation,
208
- reflink,
209
- reflinkSearch,
210
- tag,
211
- text: inlineText,
212
- url: noopTest
213
- };
214
- var inlinePedantic = {
215
- ...inlineNormal,
216
- link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
217
- reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
218
- };
219
- var inlineGfm = {
220
- ...inlineNormal,
221
- emStrongRDelimAst: emStrongRDelimAstGfm,
222
- emStrongLDelim: emStrongLDelimGfm,
223
- url: edit(/^((?: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(),
224
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
225
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
226
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
227
- };
228
- var inlineBreaks = {
229
- ...inlineGfm,
230
- br: edit(br).replace("{2,}", "*").getRegex(),
231
- text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
232
- };
233
- var block = {
234
- normal: blockNormal,
235
- gfm: blockGfm,
236
- pedantic: blockPedantic
237
- };
238
- var inline = {
239
- normal: inlineNormal,
240
- gfm: inlineGfm,
241
- breaks: inlineBreaks,
242
- pedantic: inlinePedantic
243
- };
244
- var escapeReplacements = {
245
- "&": "&amp;",
246
- "<": "&lt;",
247
- ">": "&gt;",
248
- '"': "&quot;",
249
- "'": "&#39;"
250
- };
251
- var getEscapeReplacement = /* @__PURE__ */ __name((ch) => escapeReplacements[ch], "getEscapeReplacement");
252
- function escape2(html2, encode) {
253
- if (encode) {
254
- if (other.escapeTest.test(html2)) {
255
- return html2.replace(other.escapeReplace, getEscapeReplacement);
256
- }
257
- } else {
258
- if (other.escapeTestNoEncode.test(html2)) {
259
- return html2.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
260
- }
261
- }
262
- return html2;
263
- }
264
- __name(escape2, "escape2");
265
- function cleanUrl(href) {
266
- try {
267
- href = encodeURI(href).replace(other.percentDecode, "%");
268
- } catch {
269
- return null;
270
- }
271
- return href;
272
- }
273
- __name(cleanUrl, "cleanUrl");
274
- function splitCells(tableRow, count) {
275
- var _a2;
276
- const row = tableRow.replace(other.findPipe, (match, offset, str) => {
277
- let escaped = false;
278
- let curr = offset;
279
- while (--curr >= 0 && str[curr] === "\\") escaped = !escaped;
280
- if (escaped) {
281
- return "|";
282
- } else {
283
- return " |";
284
- }
285
- }), cells = row.split(other.splitPipe);
286
- let i = 0;
287
- if (!cells[0].trim()) {
288
- cells.shift();
289
- }
290
- if (cells.length > 0 && !((_a2 = cells.at(-1)) == null ? void 0 : _a2.trim())) {
291
- cells.pop();
292
- }
293
- if (count) {
294
- if (cells.length > count) {
295
- cells.splice(count);
296
- } else {
297
- while (cells.length < count) cells.push("");
298
- }
299
- }
300
- for (; i < cells.length; i++) {
301
- cells[i] = cells[i].trim().replace(other.slashPipe, "|");
302
- }
303
- return cells;
304
- }
305
- __name(splitCells, "splitCells");
306
- function rtrim(str, c, invert) {
307
- const l = str.length;
308
- if (l === 0) {
309
- return "";
310
- }
311
- let suffLen = 0;
312
- while (suffLen < l) {
313
- const currChar = str.charAt(l - suffLen - 1);
314
- if (currChar === c && true) {
315
- suffLen++;
316
- } else {
317
- break;
318
- }
319
- }
320
- return str.slice(0, l - suffLen);
321
- }
322
- __name(rtrim, "rtrim");
323
- function findClosingBracket(str, b) {
324
- if (str.indexOf(b[1]) === -1) {
325
- return -1;
326
- }
327
- let level = 0;
328
- for (let i = 0; i < str.length; i++) {
329
- if (str[i] === "\\") {
330
- i++;
331
- } else if (str[i] === b[0]) {
332
- level++;
333
- } else if (str[i] === b[1]) {
334
- level--;
335
- if (level < 0) {
336
- return i;
337
- }
338
- }
339
- }
340
- if (level > 0) {
341
- return -2;
342
- }
343
- return -1;
344
- }
345
- __name(findClosingBracket, "findClosingBracket");
346
- function outputLink(cap, link2, raw, lexer2, rules) {
347
- const href = link2.href;
348
- const title = link2.title || null;
349
- const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
350
- lexer2.state.inLink = true;
351
- const token = {
352
- type: cap[0].charAt(0) === "!" ? "image" : "link",
353
- raw,
354
- href,
355
- title,
356
- text,
357
- tokens: lexer2.inlineTokens(text)
358
- };
359
- lexer2.state.inLink = false;
360
- return token;
361
- }
362
- __name(outputLink, "outputLink");
363
- function indentCodeCompensation(raw, text, rules) {
364
- const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
365
- if (matchIndentToCode === null) {
366
- return text;
367
- }
368
- const indentToCode = matchIndentToCode[1];
369
- return text.split("\n").map((node) => {
370
- const matchIndentInNode = node.match(rules.other.beginningSpace);
371
- if (matchIndentInNode === null) {
372
- return node;
373
- }
374
- const [indentInNode] = matchIndentInNode;
375
- if (indentInNode.length >= indentToCode.length) {
376
- return node.slice(indentToCode.length);
377
- }
378
- return node;
379
- }).join("\n");
380
- }
381
- __name(indentCodeCompensation, "indentCodeCompensation");
382
- var _Tokenizer = (_a = class {
383
- // set by the lexer
384
- constructor(options2) {
385
- __publicField(this, "options");
386
- __publicField(this, "rules");
387
- // set by the lexer
388
- __publicField(this, "lexer");
389
- this.options = options2 || _defaults;
390
- }
391
- space(src) {
392
- const cap = this.rules.block.newline.exec(src);
393
- if (cap && cap[0].length > 0) {
394
- return {
395
- type: "space",
396
- raw: cap[0]
397
- };
398
- }
399
- }
400
- code(src) {
401
- const cap = this.rules.block.code.exec(src);
402
- if (cap) {
403
- const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
404
- return {
405
- type: "code",
406
- raw: cap[0],
407
- codeBlockStyle: "indented",
408
- text: !this.options.pedantic ? rtrim(text, "\n") : text
409
- };
410
- }
411
- }
412
- fences(src) {
413
- const cap = this.rules.block.fences.exec(src);
414
- if (cap) {
415
- const raw = cap[0];
416
- const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
417
- return {
418
- type: "code",
419
- raw,
420
- lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
421
- text
422
- };
423
- }
424
- }
425
- heading(src) {
426
- const cap = this.rules.block.heading.exec(src);
427
- if (cap) {
428
- let text = cap[2].trim();
429
- if (this.rules.other.endingHash.test(text)) {
430
- const trimmed = rtrim(text, "#");
431
- if (this.options.pedantic) {
432
- text = trimmed.trim();
433
- } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
434
- text = trimmed.trim();
435
- }
436
- }
437
- return {
438
- type: "heading",
439
- raw: cap[0],
440
- depth: cap[1].length,
441
- text,
442
- tokens: this.lexer.inline(text)
443
- };
444
- }
445
- }
446
- hr(src) {
447
- const cap = this.rules.block.hr.exec(src);
448
- if (cap) {
449
- return {
450
- type: "hr",
451
- raw: rtrim(cap[0], "\n")
452
- };
453
- }
454
- }
455
- blockquote(src) {
456
- const cap = this.rules.block.blockquote.exec(src);
457
- if (cap) {
458
- let lines = rtrim(cap[0], "\n").split("\n");
459
- let raw = "";
460
- let text = "";
461
- const tokens = [];
462
- while (lines.length > 0) {
463
- let inBlockquote = false;
464
- const currentLines = [];
465
- let i;
466
- for (i = 0; i < lines.length; i++) {
467
- if (this.rules.other.blockquoteStart.test(lines[i])) {
468
- currentLines.push(lines[i]);
469
- inBlockquote = true;
470
- } else if (!inBlockquote) {
471
- currentLines.push(lines[i]);
472
- } else {
473
- break;
474
- }
475
- }
476
- lines = lines.slice(i);
477
- const currentRaw = currentLines.join("\n");
478
- const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
479
- raw = raw ? `${raw}
480
- ${currentRaw}` : currentRaw;
481
- text = text ? `${text}
482
- ${currentText}` : currentText;
483
- const top = this.lexer.state.top;
484
- this.lexer.state.top = true;
485
- this.lexer.blockTokens(currentText, tokens, true);
486
- this.lexer.state.top = top;
487
- if (lines.length === 0) {
488
- break;
489
- }
490
- const lastToken = tokens.at(-1);
491
- if ((lastToken == null ? void 0 : lastToken.type) === "code") {
492
- break;
493
- } else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
494
- const oldToken = lastToken;
495
- const newText = oldToken.raw + "\n" + lines.join("\n");
496
- const newToken = this.blockquote(newText);
497
- tokens[tokens.length - 1] = newToken;
498
- raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
499
- text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
500
- break;
501
- } else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
502
- const oldToken = lastToken;
503
- const newText = oldToken.raw + "\n" + lines.join("\n");
504
- const newToken = this.list(newText);
505
- tokens[tokens.length - 1] = newToken;
506
- raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
507
- text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
508
- lines = newText.substring(tokens.at(-1).raw.length).split("\n");
509
- continue;
510
- }
511
- }
512
- return {
513
- type: "blockquote",
514
- raw,
515
- tokens,
516
- text
517
- };
518
- }
519
- }
520
- list(src) {
521
- let cap = this.rules.block.list.exec(src);
522
- if (cap) {
523
- let bull = cap[1].trim();
524
- const isordered = bull.length > 1;
525
- const list2 = {
526
- type: "list",
527
- raw: "",
528
- ordered: isordered,
529
- start: isordered ? +bull.slice(0, -1) : "",
530
- loose: false,
531
- items: []
532
- };
533
- bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
534
- if (this.options.pedantic) {
535
- bull = isordered ? bull : "[*+-]";
536
- }
537
- const itemRegex = this.rules.other.listItemRegex(bull);
538
- let endsWithBlankLine = false;
539
- while (src) {
540
- let endEarly = false;
541
- let raw = "";
542
- let itemContents = "";
543
- if (!(cap = itemRegex.exec(src))) {
544
- break;
545
- }
546
- if (this.rules.block.hr.test(src)) {
547
- break;
548
- }
549
- raw = cap[0];
550
- src = src.substring(raw.length);
551
- let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t) => " ".repeat(3 * t.length));
552
- let nextLine = src.split("\n", 1)[0];
553
- let blankLine = !line.trim();
554
- let indent = 0;
555
- if (this.options.pedantic) {
556
- indent = 2;
557
- itemContents = line.trimStart();
558
- } else if (blankLine) {
559
- indent = cap[1].length + 1;
560
- } else {
561
- indent = cap[2].search(this.rules.other.nonSpaceChar);
562
- indent = indent > 4 ? 1 : indent;
563
- itemContents = line.slice(indent);
564
- indent += cap[1].length;
565
- }
566
- if (blankLine && this.rules.other.blankLine.test(nextLine)) {
567
- raw += nextLine + "\n";
568
- src = src.substring(nextLine.length + 1);
569
- endEarly = true;
570
- }
571
- if (!endEarly) {
572
- const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
573
- const hrRegex = this.rules.other.hrRegex(indent);
574
- const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
575
- const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
576
- const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
577
- while (src) {
578
- const rawLine = src.split("\n", 1)[0];
579
- let nextLineWithoutTabs;
580
- nextLine = rawLine;
581
- if (this.options.pedantic) {
582
- nextLine = nextLine.replace(this.rules.other.listReplaceNesting, " ");
583
- nextLineWithoutTabs = nextLine;
584
- } else {
585
- nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, " ");
586
- }
587
- if (fencesBeginRegex.test(nextLine)) {
588
- break;
589
- }
590
- if (headingBeginRegex.test(nextLine)) {
591
- break;
592
- }
593
- if (htmlBeginRegex.test(nextLine)) {
594
- break;
595
- }
596
- if (nextBulletRegex.test(nextLine)) {
597
- break;
598
- }
599
- if (hrRegex.test(nextLine)) {
600
- break;
601
- }
602
- if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
603
- itemContents += "\n" + nextLineWithoutTabs.slice(indent);
604
- } else {
605
- if (blankLine) {
606
- break;
607
- }
608
- if (line.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4) {
609
- break;
610
- }
611
- if (fencesBeginRegex.test(line)) {
612
- break;
613
- }
614
- if (headingBeginRegex.test(line)) {
615
- break;
616
- }
617
- if (hrRegex.test(line)) {
618
- break;
619
- }
620
- itemContents += "\n" + nextLine;
621
- }
622
- if (!blankLine && !nextLine.trim()) {
623
- blankLine = true;
624
- }
625
- raw += rawLine + "\n";
626
- src = src.substring(rawLine.length + 1);
627
- line = nextLineWithoutTabs.slice(indent);
628
- }
629
- }
630
- if (!list2.loose) {
631
- if (endsWithBlankLine) {
632
- list2.loose = true;
633
- } else if (this.rules.other.doubleBlankLine.test(raw)) {
634
- endsWithBlankLine = true;
635
- }
636
- }
637
- let istask = null;
638
- let ischecked;
639
- if (this.options.gfm) {
640
- istask = this.rules.other.listIsTask.exec(itemContents);
641
- if (istask) {
642
- ischecked = istask[0] !== "[ ] ";
643
- itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
644
- }
645
- }
646
- list2.items.push({
647
- type: "list_item",
648
- raw,
649
- task: !!istask,
650
- checked: ischecked,
651
- loose: false,
652
- text: itemContents,
653
- tokens: []
654
- });
655
- list2.raw += raw;
656
- }
657
- const lastItem = list2.items.at(-1);
658
- if (lastItem) {
659
- lastItem.raw = lastItem.raw.trimEnd();
660
- lastItem.text = lastItem.text.trimEnd();
661
- } else {
662
- return;
663
- }
664
- list2.raw = list2.raw.trimEnd();
665
- for (let i = 0; i < list2.items.length; i++) {
666
- this.lexer.state.top = false;
667
- list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
668
- if (!list2.loose) {
669
- const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
670
- const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => this.rules.other.anyLine.test(t.raw));
671
- list2.loose = hasMultipleLineBreaks;
672
- }
673
- }
674
- if (list2.loose) {
675
- for (let i = 0; i < list2.items.length; i++) {
676
- list2.items[i].loose = true;
677
- }
678
- }
679
- return list2;
680
- }
681
- }
682
- html(src) {
683
- const cap = this.rules.block.html.exec(src);
684
- if (cap) {
685
- const token = {
686
- type: "html",
687
- block: true,
688
- raw: cap[0],
689
- pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
690
- text: cap[0]
691
- };
692
- return token;
693
- }
694
- }
695
- def(src) {
696
- const cap = this.rules.block.def.exec(src);
697
- if (cap) {
698
- const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
699
- const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
700
- const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
701
- return {
702
- type: "def",
703
- tag: tag2,
704
- raw: cap[0],
705
- href,
706
- title
707
- };
708
- }
709
- }
710
- table(src) {
711
- var _a2;
712
- const cap = this.rules.block.table.exec(src);
713
- if (!cap) {
714
- return;
715
- }
716
- if (!this.rules.other.tableDelimiter.test(cap[2])) {
717
- return;
718
- }
719
- const headers = splitCells(cap[1]);
720
- const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
721
- const rows = ((_a2 = cap[3]) == null ? void 0 : _a2.trim()) ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
722
- const item = {
723
- type: "table",
724
- raw: cap[0],
725
- header: [],
726
- align: [],
727
- rows: []
728
- };
729
- if (headers.length !== aligns.length) {
730
- return;
731
- }
732
- for (const align of aligns) {
733
- if (this.rules.other.tableAlignRight.test(align)) {
734
- item.align.push("right");
735
- } else if (this.rules.other.tableAlignCenter.test(align)) {
736
- item.align.push("center");
737
- } else if (this.rules.other.tableAlignLeft.test(align)) {
738
- item.align.push("left");
739
- } else {
740
- item.align.push(null);
741
- }
742
- }
743
- for (let i = 0; i < headers.length; i++) {
744
- item.header.push({
745
- text: headers[i],
746
- tokens: this.lexer.inline(headers[i]),
747
- header: true,
748
- align: item.align[i]
749
- });
750
- }
751
- for (const row of rows) {
752
- item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
753
- return {
754
- text: cell,
755
- tokens: this.lexer.inline(cell),
756
- header: false,
757
- align: item.align[i]
758
- };
759
- }));
760
- }
761
- return item;
762
- }
763
- lheading(src) {
764
- const cap = this.rules.block.lheading.exec(src);
765
- if (cap) {
766
- return {
767
- type: "heading",
768
- raw: cap[0],
769
- depth: cap[2].charAt(0) === "=" ? 1 : 2,
770
- text: cap[1],
771
- tokens: this.lexer.inline(cap[1])
772
- };
773
- }
774
- }
775
- paragraph(src) {
776
- const cap = this.rules.block.paragraph.exec(src);
777
- if (cap) {
778
- const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
779
- return {
780
- type: "paragraph",
781
- raw: cap[0],
782
- text,
783
- tokens: this.lexer.inline(text)
784
- };
785
- }
786
- }
787
- text(src) {
788
- const cap = this.rules.block.text.exec(src);
789
- if (cap) {
790
- return {
791
- type: "text",
792
- raw: cap[0],
793
- text: cap[0],
794
- tokens: this.lexer.inline(cap[0])
795
- };
796
- }
797
- }
798
- escape(src) {
799
- const cap = this.rules.inline.escape.exec(src);
800
- if (cap) {
801
- return {
802
- type: "escape",
803
- raw: cap[0],
804
- text: cap[1]
805
- };
806
- }
807
- }
808
- tag(src) {
809
- const cap = this.rules.inline.tag.exec(src);
810
- if (cap) {
811
- if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
812
- this.lexer.state.inLink = true;
813
- } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
814
- this.lexer.state.inLink = false;
815
- }
816
- if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
817
- this.lexer.state.inRawBlock = true;
818
- } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
819
- this.lexer.state.inRawBlock = false;
820
- }
821
- return {
822
- type: "html",
823
- raw: cap[0],
824
- inLink: this.lexer.state.inLink,
825
- inRawBlock: this.lexer.state.inRawBlock,
826
- block: false,
827
- text: cap[0]
828
- };
829
- }
830
- }
831
- link(src) {
832
- const cap = this.rules.inline.link.exec(src);
833
- if (cap) {
834
- const trimmedUrl = cap[2].trim();
835
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
836
- if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
837
- return;
838
- }
839
- const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
840
- if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
841
- return;
842
- }
843
- } else {
844
- const lastParenIndex = findClosingBracket(cap[2], "()");
845
- if (lastParenIndex === -2) {
846
- return;
847
- }
848
- if (lastParenIndex > -1) {
849
- const start = cap[0].indexOf("!") === 0 ? 5 : 4;
850
- const linkLen = start + cap[1].length + lastParenIndex;
851
- cap[2] = cap[2].substring(0, lastParenIndex);
852
- cap[0] = cap[0].substring(0, linkLen).trim();
853
- cap[3] = "";
854
- }
855
- }
856
- let href = cap[2];
857
- let title = "";
858
- if (this.options.pedantic) {
859
- const link2 = this.rules.other.pedanticHrefTitle.exec(href);
860
- if (link2) {
861
- href = link2[1];
862
- title = link2[3];
863
- }
864
- } else {
865
- title = cap[3] ? cap[3].slice(1, -1) : "";
866
- }
867
- href = href.trim();
868
- if (this.rules.other.startAngleBracket.test(href)) {
869
- if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
870
- href = href.slice(1);
871
- } else {
872
- href = href.slice(1, -1);
873
- }
874
- }
875
- return outputLink(cap, {
876
- href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
877
- title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
878
- }, cap[0], this.lexer, this.rules);
879
- }
880
- }
881
- reflink(src, links) {
882
- let cap;
883
- if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
884
- const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
885
- const link2 = links[linkString.toLowerCase()];
886
- if (!link2) {
887
- const text = cap[0].charAt(0);
888
- return {
889
- type: "text",
890
- raw: text,
891
- text
892
- };
893
- }
894
- return outputLink(cap, link2, cap[0], this.lexer, this.rules);
895
- }
896
- }
897
- emStrong(src, maskedSrc, prevChar = "") {
898
- let match = this.rules.inline.emStrongLDelim.exec(src);
899
- if (!match) return;
900
- if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric)) return;
901
- const nextChar = match[1] || match[2] || "";
902
- if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
903
- const lLength = [...match[0]].length - 1;
904
- let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
905
- const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
906
- endReg.lastIndex = 0;
907
- maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
908
- while ((match = endReg.exec(maskedSrc)) != null) {
909
- rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
910
- if (!rDelim) continue;
911
- rLength = [...rDelim].length;
912
- if (match[3] || match[4]) {
913
- delimTotal += rLength;
914
- continue;
915
- } else if (match[5] || match[6]) {
916
- if (lLength % 3 && !((lLength + rLength) % 3)) {
917
- midDelimTotal += rLength;
918
- continue;
919
- }
920
- }
921
- delimTotal -= rLength;
922
- if (delimTotal > 0) continue;
923
- rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
924
- const lastCharLength = [...match[0]][0].length;
925
- const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
926
- if (Math.min(lLength, rLength) % 2) {
927
- const text2 = raw.slice(1, -1);
928
- return {
929
- type: "em",
930
- raw,
931
- text: text2,
932
- tokens: this.lexer.inlineTokens(text2)
933
- };
934
- }
935
- const text = raw.slice(2, -2);
936
- return {
937
- type: "strong",
938
- raw,
939
- text,
940
- tokens: this.lexer.inlineTokens(text)
941
- };
942
- }
943
- }
944
- }
945
- codespan(src) {
946
- const cap = this.rules.inline.code.exec(src);
947
- if (cap) {
948
- let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
949
- const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
950
- const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
951
- if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
952
- text = text.substring(1, text.length - 1);
953
- }
954
- return {
955
- type: "codespan",
956
- raw: cap[0],
957
- text
958
- };
959
- }
960
- }
961
- br(src) {
962
- const cap = this.rules.inline.br.exec(src);
963
- if (cap) {
964
- return {
965
- type: "br",
966
- raw: cap[0]
967
- };
968
- }
969
- }
970
- del(src) {
971
- const cap = this.rules.inline.del.exec(src);
972
- if (cap) {
973
- return {
974
- type: "del",
975
- raw: cap[0],
976
- text: cap[2],
977
- tokens: this.lexer.inlineTokens(cap[2])
978
- };
979
- }
980
- }
981
- autolink(src) {
982
- const cap = this.rules.inline.autolink.exec(src);
983
- if (cap) {
984
- let text, href;
985
- if (cap[2] === "@") {
986
- text = cap[1];
987
- href = "mailto:" + text;
988
- } else {
989
- text = cap[1];
990
- href = text;
991
- }
992
- return {
993
- type: "link",
994
- raw: cap[0],
995
- text,
996
- href,
997
- tokens: [
998
- {
999
- type: "text",
1000
- raw: text,
1001
- text
1002
- }
1003
- ]
1004
- };
1005
- }
1006
- }
1007
- url(src) {
1008
- var _a2;
1009
- let cap;
1010
- if (cap = this.rules.inline.url.exec(src)) {
1011
- let text, href;
1012
- if (cap[2] === "@") {
1013
- text = cap[0];
1014
- href = "mailto:" + text;
1015
- } else {
1016
- let prevCapZero;
1017
- do {
1018
- prevCapZero = cap[0];
1019
- cap[0] = ((_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) ?? "";
1020
- } while (prevCapZero !== cap[0]);
1021
- text = cap[0];
1022
- if (cap[1] === "www.") {
1023
- href = "http://" + cap[0];
1024
- } else {
1025
- href = cap[0];
1026
- }
1027
- }
1028
- return {
1029
- type: "link",
1030
- raw: cap[0],
1031
- text,
1032
- href,
1033
- tokens: [
1034
- {
1035
- type: "text",
1036
- raw: text,
1037
- text
1038
- }
1039
- ]
1040
- };
1041
- }
1042
- }
1043
- inlineText(src) {
1044
- const cap = this.rules.inline.text.exec(src);
1045
- if (cap) {
1046
- const escaped = this.lexer.state.inRawBlock;
1047
- return {
1048
- type: "text",
1049
- raw: cap[0],
1050
- text: cap[0],
1051
- escaped
1052
- };
1053
- }
1054
- }
1055
- }, __name(_a, "_Tokenizer"), _a);
1056
- var _Lexer = (_b = class {
1057
- constructor(options2) {
1058
- __publicField(this, "tokens");
1059
- __publicField(this, "options");
1060
- __publicField(this, "state");
1061
- __publicField(this, "tokenizer");
1062
- __publicField(this, "inlineQueue");
1063
- this.tokens = [];
1064
- this.tokens.links = /* @__PURE__ */ Object.create(null);
1065
- this.options = options2 || _defaults;
1066
- this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1067
- this.tokenizer = this.options.tokenizer;
1068
- this.tokenizer.options = this.options;
1069
- this.tokenizer.lexer = this;
1070
- this.inlineQueue = [];
1071
- this.state = {
1072
- inLink: false,
1073
- inRawBlock: false,
1074
- top: true
1075
- };
1076
- const rules = {
1077
- other,
1078
- block: block.normal,
1079
- inline: inline.normal
1080
- };
1081
- if (this.options.pedantic) {
1082
- rules.block = block.pedantic;
1083
- rules.inline = inline.pedantic;
1084
- } else if (this.options.gfm) {
1085
- rules.block = block.gfm;
1086
- if (this.options.breaks) {
1087
- rules.inline = inline.breaks;
1088
- } else {
1089
- rules.inline = inline.gfm;
1090
- }
1091
- }
1092
- this.tokenizer.rules = rules;
1093
- }
1094
- /**
1095
- * Expose Rules
1096
- */
1097
- static get rules() {
1098
- return {
1099
- block,
1100
- inline
1101
- };
1102
- }
1103
- /**
1104
- * Static Lex Method
1105
- */
1106
- static lex(src, options2) {
1107
- const lexer2 = new _b(options2);
1108
- return lexer2.lex(src);
1109
- }
1110
- /**
1111
- * Static Lex Inline Method
1112
- */
1113
- static lexInline(src, options2) {
1114
- const lexer2 = new _b(options2);
1115
- return lexer2.inlineTokens(src);
1116
- }
1117
- /**
1118
- * Preprocessing
1119
- */
1120
- lex(src) {
1121
- src = src.replace(other.carriageReturn, "\n");
1122
- this.blockTokens(src, this.tokens);
1123
- for (let i = 0; i < this.inlineQueue.length; i++) {
1124
- const next = this.inlineQueue[i];
1125
- this.inlineTokens(next.src, next.tokens);
1126
- }
1127
- this.inlineQueue = [];
1128
- return this.tokens;
1129
- }
1130
- blockTokens(src, tokens = [], lastParagraphClipped = false) {
1131
- var _a2, _b2, _c2;
1132
- if (this.options.pedantic) {
1133
- src = src.replace(other.tabCharGlobal, " ").replace(other.spaceLine, "");
1134
- }
1135
- while (src) {
1136
- let token;
1137
- if ((_b2 = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b2.some((extTokenizer) => {
1138
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1139
- src = src.substring(token.raw.length);
1140
- tokens.push(token);
1141
- return true;
1142
- }
1143
- return false;
1144
- })) {
1145
- continue;
1146
- }
1147
- if (token = this.tokenizer.space(src)) {
1148
- src = src.substring(token.raw.length);
1149
- const lastToken = tokens.at(-1);
1150
- if (token.raw.length === 1 && lastToken !== void 0) {
1151
- lastToken.raw += "\n";
1152
- } else {
1153
- tokens.push(token);
1154
- }
1155
- continue;
1156
- }
1157
- if (token = this.tokenizer.code(src)) {
1158
- src = src.substring(token.raw.length);
1159
- const lastToken = tokens.at(-1);
1160
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1161
- lastToken.raw += "\n" + token.raw;
1162
- lastToken.text += "\n" + token.text;
1163
- this.inlineQueue.at(-1).src = lastToken.text;
1164
- } else {
1165
- tokens.push(token);
1166
- }
1167
- continue;
1168
- }
1169
- if (token = this.tokenizer.fences(src)) {
1170
- src = src.substring(token.raw.length);
1171
- tokens.push(token);
1172
- continue;
1173
- }
1174
- if (token = this.tokenizer.heading(src)) {
1175
- src = src.substring(token.raw.length);
1176
- tokens.push(token);
1177
- continue;
1178
- }
1179
- if (token = this.tokenizer.hr(src)) {
1180
- src = src.substring(token.raw.length);
1181
- tokens.push(token);
1182
- continue;
1183
- }
1184
- if (token = this.tokenizer.blockquote(src)) {
1185
- src = src.substring(token.raw.length);
1186
- tokens.push(token);
1187
- continue;
1188
- }
1189
- if (token = this.tokenizer.list(src)) {
1190
- src = src.substring(token.raw.length);
1191
- tokens.push(token);
1192
- continue;
1193
- }
1194
- if (token = this.tokenizer.html(src)) {
1195
- src = src.substring(token.raw.length);
1196
- tokens.push(token);
1197
- continue;
1198
- }
1199
- if (token = this.tokenizer.def(src)) {
1200
- src = src.substring(token.raw.length);
1201
- const lastToken = tokens.at(-1);
1202
- if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
1203
- lastToken.raw += "\n" + token.raw;
1204
- lastToken.text += "\n" + token.raw;
1205
- this.inlineQueue.at(-1).src = lastToken.text;
1206
- } else if (!this.tokens.links[token.tag]) {
1207
- this.tokens.links[token.tag] = {
1208
- href: token.href,
1209
- title: token.title
1210
- };
1211
- }
1212
- continue;
1213
- }
1214
- if (token = this.tokenizer.table(src)) {
1215
- src = src.substring(token.raw.length);
1216
- tokens.push(token);
1217
- continue;
1218
- }
1219
- if (token = this.tokenizer.lheading(src)) {
1220
- src = src.substring(token.raw.length);
1221
- tokens.push(token);
1222
- continue;
1223
- }
1224
- let cutSrc = src;
1225
- if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startBlock) {
1226
- let startIndex = Infinity;
1227
- const tempSrc = src.slice(1);
1228
- let tempStart;
1229
- this.options.extensions.startBlock.forEach((getStartIndex) => {
1230
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1231
- if (typeof tempStart === "number" && tempStart >= 0) {
1232
- startIndex = Math.min(startIndex, tempStart);
1233
- }
1234
- });
1235
- if (startIndex < Infinity && startIndex >= 0) {
1236
- cutSrc = src.substring(0, startIndex + 1);
1237
- }
1238
- }
1239
- if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1240
- const lastToken = tokens.at(-1);
1241
- if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
1242
- lastToken.raw += "\n" + token.raw;
1243
- lastToken.text += "\n" + token.text;
1244
- this.inlineQueue.pop();
1245
- this.inlineQueue.at(-1).src = lastToken.text;
1246
- } else {
1247
- tokens.push(token);
1248
- }
1249
- lastParagraphClipped = cutSrc.length !== src.length;
1250
- src = src.substring(token.raw.length);
1251
- continue;
1252
- }
1253
- if (token = this.tokenizer.text(src)) {
1254
- src = src.substring(token.raw.length);
1255
- const lastToken = tokens.at(-1);
1256
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
1257
- lastToken.raw += "\n" + token.raw;
1258
- lastToken.text += "\n" + token.text;
1259
- this.inlineQueue.pop();
1260
- this.inlineQueue.at(-1).src = lastToken.text;
1261
- } else {
1262
- tokens.push(token);
1263
- }
1264
- continue;
1265
- }
1266
- if (src) {
1267
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1268
- if (this.options.silent) {
1269
- console.error(errMsg);
1270
- break;
1271
- } else {
1272
- throw new Error(errMsg);
1273
- }
1274
- }
1275
- }
1276
- this.state.top = true;
1277
- return tokens;
1278
- }
1279
- inline(src, tokens = []) {
1280
- this.inlineQueue.push({ src, tokens });
1281
- return tokens;
1282
- }
1283
- /**
1284
- * Lexing/Compiling
1285
- */
1286
- inlineTokens(src, tokens = []) {
1287
- var _a2, _b2, _c2;
1288
- let maskedSrc = src;
1289
- let match = null;
1290
- if (this.tokens.links) {
1291
- const links = Object.keys(this.tokens.links);
1292
- if (links.length > 0) {
1293
- while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1294
- if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1295
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1296
- }
1297
- }
1298
- }
1299
- }
1300
- while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1301
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1302
- }
1303
- while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1304
- maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1305
- }
1306
- let keepPrevChar = false;
1307
- let prevChar = "";
1308
- while (src) {
1309
- if (!keepPrevChar) {
1310
- prevChar = "";
1311
- }
1312
- keepPrevChar = false;
1313
- let token;
1314
- if ((_b2 = (_a2 = this.options.extensions) == null ? void 0 : _a2.inline) == null ? void 0 : _b2.some((extTokenizer) => {
1315
- if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1316
- src = src.substring(token.raw.length);
1317
- tokens.push(token);
1318
- return true;
1319
- }
1320
- return false;
1321
- })) {
1322
- continue;
1323
- }
1324
- if (token = this.tokenizer.escape(src)) {
1325
- src = src.substring(token.raw.length);
1326
- tokens.push(token);
1327
- continue;
1328
- }
1329
- if (token = this.tokenizer.tag(src)) {
1330
- src = src.substring(token.raw.length);
1331
- tokens.push(token);
1332
- continue;
1333
- }
1334
- if (token = this.tokenizer.link(src)) {
1335
- src = src.substring(token.raw.length);
1336
- tokens.push(token);
1337
- continue;
1338
- }
1339
- if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1340
- src = src.substring(token.raw.length);
1341
- const lastToken = tokens.at(-1);
1342
- if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") {
1343
- lastToken.raw += token.raw;
1344
- lastToken.text += token.text;
1345
- } else {
1346
- tokens.push(token);
1347
- }
1348
- continue;
1349
- }
1350
- if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1351
- src = src.substring(token.raw.length);
1352
- tokens.push(token);
1353
- continue;
1354
- }
1355
- if (token = this.tokenizer.codespan(src)) {
1356
- src = src.substring(token.raw.length);
1357
- tokens.push(token);
1358
- continue;
1359
- }
1360
- if (token = this.tokenizer.br(src)) {
1361
- src = src.substring(token.raw.length);
1362
- tokens.push(token);
1363
- continue;
1364
- }
1365
- if (token = this.tokenizer.del(src)) {
1366
- src = src.substring(token.raw.length);
1367
- tokens.push(token);
1368
- continue;
1369
- }
1370
- if (token = this.tokenizer.autolink(src)) {
1371
- src = src.substring(token.raw.length);
1372
- tokens.push(token);
1373
- continue;
1374
- }
1375
- if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1376
- src = src.substring(token.raw.length);
1377
- tokens.push(token);
1378
- continue;
1379
- }
1380
- let cutSrc = src;
1381
- if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startInline) {
1382
- let startIndex = Infinity;
1383
- const tempSrc = src.slice(1);
1384
- let tempStart;
1385
- this.options.extensions.startInline.forEach((getStartIndex) => {
1386
- tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1387
- if (typeof tempStart === "number" && tempStart >= 0) {
1388
- startIndex = Math.min(startIndex, tempStart);
1389
- }
1390
- });
1391
- if (startIndex < Infinity && startIndex >= 0) {
1392
- cutSrc = src.substring(0, startIndex + 1);
1393
- }
1394
- }
1395
- if (token = this.tokenizer.inlineText(cutSrc)) {
1396
- src = src.substring(token.raw.length);
1397
- if (token.raw.slice(-1) !== "_") {
1398
- prevChar = token.raw.slice(-1);
1399
- }
1400
- keepPrevChar = true;
1401
- const lastToken = tokens.at(-1);
1402
- if ((lastToken == null ? void 0 : lastToken.type) === "text") {
1403
- lastToken.raw += token.raw;
1404
- lastToken.text += token.text;
1405
- } else {
1406
- tokens.push(token);
1407
- }
1408
- continue;
1409
- }
1410
- if (src) {
1411
- const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1412
- if (this.options.silent) {
1413
- console.error(errMsg);
1414
- break;
1415
- } else {
1416
- throw new Error(errMsg);
1417
- }
1418
- }
1419
- }
1420
- return tokens;
1421
- }
1422
- }, __name(_b, "__Lexer"), _b);
1423
- var _Renderer = (_c = class {
1424
- // set by the parser
1425
- constructor(options2) {
1426
- __publicField(this, "options");
1427
- __publicField(this, "parser");
1428
- this.options = options2 || _defaults;
1429
- }
1430
- space(token) {
1431
- return "";
1432
- }
1433
- code({ text, lang, escaped }) {
1434
- var _a2;
1435
- const langString = (_a2 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a2[0];
1436
- const code = text.replace(other.endingNewline, "") + "\n";
1437
- if (!langString) {
1438
- return "<pre><code>" + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
1439
- }
1440
- return '<pre><code class="language-' + escape2(langString) + '">' + (escaped ? code : escape2(code, true)) + "</code></pre>\n";
1441
- }
1442
- blockquote({ tokens }) {
1443
- const body = this.parser.parse(tokens);
1444
- return `<blockquote>
1445
- ${body}</blockquote>
1446
- `;
1447
- }
1448
- html({ text }) {
1449
- return text;
1450
- }
1451
- heading({ tokens, depth }) {
1452
- return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
1453
- `;
1454
- }
1455
- hr(token) {
1456
- return "<hr>\n";
1457
- }
1458
- list(token) {
1459
- const ordered = token.ordered;
1460
- const start = token.start;
1461
- let body = "";
1462
- for (let j = 0; j < token.items.length; j++) {
1463
- const item = token.items[j];
1464
- body += this.listitem(item);
1465
- }
1466
- const type = ordered ? "ol" : "ul";
1467
- const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
1468
- return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
1469
- }
1470
- listitem(item) {
1471
- var _a2;
1472
- let itemBody = "";
1473
- if (item.task) {
1474
- const checkbox = this.checkbox({ checked: !!item.checked });
1475
- if (item.loose) {
1476
- if (((_a2 = item.tokens[0]) == null ? void 0 : _a2.type) === "paragraph") {
1477
- item.tokens[0].text = checkbox + " " + item.tokens[0].text;
1478
- if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
1479
- item.tokens[0].tokens[0].text = checkbox + " " + escape2(item.tokens[0].tokens[0].text);
1480
- item.tokens[0].tokens[0].escaped = true;
1481
- }
1482
- } else {
1483
- item.tokens.unshift({
1484
- type: "text",
1485
- raw: checkbox + " ",
1486
- text: checkbox + " ",
1487
- escaped: true
1488
- });
1489
- }
1490
- } else {
1491
- itemBody += checkbox + " ";
1492
- }
1493
- }
1494
- itemBody += this.parser.parse(item.tokens, !!item.loose);
1495
- return `<li>${itemBody}</li>
1496
- `;
1497
- }
1498
- checkbox({ checked }) {
1499
- return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1500
- }
1501
- paragraph({ tokens }) {
1502
- return `<p>${this.parser.parseInline(tokens)}</p>
1503
- `;
1504
- }
1505
- table(token) {
1506
- let header = "";
1507
- let cell = "";
1508
- for (let j = 0; j < token.header.length; j++) {
1509
- cell += this.tablecell(token.header[j]);
1510
- }
1511
- header += this.tablerow({ text: cell });
1512
- let body = "";
1513
- for (let j = 0; j < token.rows.length; j++) {
1514
- const row = token.rows[j];
1515
- cell = "";
1516
- for (let k = 0; k < row.length; k++) {
1517
- cell += this.tablecell(row[k]);
1518
- }
1519
- body += this.tablerow({ text: cell });
1520
- }
1521
- if (body) body = `<tbody>${body}</tbody>`;
1522
- return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
1523
- }
1524
- tablerow({ text }) {
1525
- return `<tr>
1526
- ${text}</tr>
1527
- `;
1528
- }
1529
- tablecell(token) {
1530
- const content = this.parser.parseInline(token.tokens);
1531
- const type = token.header ? "th" : "td";
1532
- const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
1533
- return tag2 + content + `</${type}>
1534
- `;
1535
- }
1536
- /**
1537
- * span level renderer
1538
- */
1539
- strong({ tokens }) {
1540
- return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1541
- }
1542
- em({ tokens }) {
1543
- return `<em>${this.parser.parseInline(tokens)}</em>`;
1544
- }
1545
- codespan({ text }) {
1546
- return `<code>${escape2(text, true)}</code>`;
1547
- }
1548
- br(token) {
1549
- return "<br>";
1550
- }
1551
- del({ tokens }) {
1552
- return `<del>${this.parser.parseInline(tokens)}</del>`;
1553
- }
1554
- link({ href, title, tokens }) {
1555
- const text = this.parser.parseInline(tokens);
1556
- const cleanHref = cleanUrl(href);
1557
- if (cleanHref === null) {
1558
- return text;
1559
- }
1560
- href = cleanHref;
1561
- let out = '<a href="' + href + '"';
1562
- if (title) {
1563
- out += ' title="' + escape2(title) + '"';
1564
- }
1565
- out += ">" + text + "</a>";
1566
- return out;
1567
- }
1568
- image({ href, title, text, tokens }) {
1569
- if (tokens) {
1570
- text = this.parser.parseInline(tokens, this.parser.textRenderer);
1571
- }
1572
- const cleanHref = cleanUrl(href);
1573
- if (cleanHref === null) {
1574
- return escape2(text);
1575
- }
1576
- href = cleanHref;
1577
- let out = `<img src="${href}" alt="${text}"`;
1578
- if (title) {
1579
- out += ` title="${escape2(title)}"`;
1580
- }
1581
- out += ">";
1582
- return out;
1583
- }
1584
- text(token) {
1585
- return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape2(token.text);
1586
- }
1587
- }, __name(_c, "_Renderer"), _c);
1588
- var _TextRenderer = (_d = class {
1589
- // no need for block level renderers
1590
- strong({ text }) {
1591
- return text;
1592
- }
1593
- em({ text }) {
1594
- return text;
1595
- }
1596
- codespan({ text }) {
1597
- return text;
1598
- }
1599
- del({ text }) {
1600
- return text;
1601
- }
1602
- html({ text }) {
1603
- return text;
1604
- }
1605
- text({ text }) {
1606
- return text;
1607
- }
1608
- link({ text }) {
1609
- return "" + text;
1610
- }
1611
- image({ text }) {
1612
- return "" + text;
1613
- }
1614
- br() {
1615
- return "";
1616
- }
1617
- }, __name(_d, "_TextRenderer"), _d);
1618
- var _Parser = (_e = class {
1619
- constructor(options2) {
1620
- __publicField(this, "options");
1621
- __publicField(this, "renderer");
1622
- __publicField(this, "textRenderer");
1623
- this.options = options2 || _defaults;
1624
- this.options.renderer = this.options.renderer || new _Renderer();
1625
- this.renderer = this.options.renderer;
1626
- this.renderer.options = this.options;
1627
- this.renderer.parser = this;
1628
- this.textRenderer = new _TextRenderer();
1629
- }
1630
- /**
1631
- * Static Parse Method
1632
- */
1633
- static parse(tokens, options2) {
1634
- const parser2 = new _e(options2);
1635
- return parser2.parse(tokens);
1636
- }
1637
- /**
1638
- * Static Parse Inline Method
1639
- */
1640
- static parseInline(tokens, options2) {
1641
- const parser2 = new _e(options2);
1642
- return parser2.parseInline(tokens);
1643
- }
1644
- /**
1645
- * Parse Loop
1646
- */
1647
- parse(tokens, top = true) {
1648
- var _a2, _b2;
1649
- let out = "";
1650
- for (let i = 0; i < tokens.length; i++) {
1651
- const anyToken = tokens[i];
1652
- if ((_b2 = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b2[anyToken.type]) {
1653
- const genericToken = anyToken;
1654
- const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
1655
- if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
1656
- out += ret || "";
1657
- continue;
1658
- }
1659
- }
1660
- const token = anyToken;
1661
- switch (token.type) {
1662
- case "space": {
1663
- out += this.renderer.space(token);
1664
- continue;
1665
- }
1666
- case "hr": {
1667
- out += this.renderer.hr(token);
1668
- continue;
1669
- }
1670
- case "heading": {
1671
- out += this.renderer.heading(token);
1672
- continue;
1673
- }
1674
- case "code": {
1675
- out += this.renderer.code(token);
1676
- continue;
1677
- }
1678
- case "table": {
1679
- out += this.renderer.table(token);
1680
- continue;
1681
- }
1682
- case "blockquote": {
1683
- out += this.renderer.blockquote(token);
1684
- continue;
1685
- }
1686
- case "list": {
1687
- out += this.renderer.list(token);
1688
- continue;
1689
- }
1690
- case "html": {
1691
- out += this.renderer.html(token);
1692
- continue;
1693
- }
1694
- case "paragraph": {
1695
- out += this.renderer.paragraph(token);
1696
- continue;
1697
- }
1698
- case "text": {
1699
- let textToken = token;
1700
- let body = this.renderer.text(textToken);
1701
- while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
1702
- textToken = tokens[++i];
1703
- body += "\n" + this.renderer.text(textToken);
1704
- }
1705
- if (top) {
1706
- out += this.renderer.paragraph({
1707
- type: "paragraph",
1708
- raw: body,
1709
- text: body,
1710
- tokens: [{ type: "text", raw: body, text: body, escaped: true }]
1711
- });
1712
- } else {
1713
- out += body;
1714
- }
1715
- continue;
1716
- }
1717
- default: {
1718
- const errMsg = 'Token with "' + token.type + '" type was not found.';
1719
- if (this.options.silent) {
1720
- console.error(errMsg);
1721
- return "";
1722
- } else {
1723
- throw new Error(errMsg);
1724
- }
1725
- }
1726
- }
1727
- }
1728
- return out;
1729
- }
1730
- /**
1731
- * Parse Inline Tokens
1732
- */
1733
- parseInline(tokens, renderer = this.renderer) {
1734
- var _a2, _b2;
1735
- let out = "";
1736
- for (let i = 0; i < tokens.length; i++) {
1737
- const anyToken = tokens[i];
1738
- if ((_b2 = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b2[anyToken.type]) {
1739
- const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
1740
- if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
1741
- out += ret || "";
1742
- continue;
1743
- }
1744
- }
1745
- const token = anyToken;
1746
- switch (token.type) {
1747
- case "escape": {
1748
- out += renderer.text(token);
1749
- break;
1750
- }
1751
- case "html": {
1752
- out += renderer.html(token);
1753
- break;
1754
- }
1755
- case "link": {
1756
- out += renderer.link(token);
1757
- break;
1758
- }
1759
- case "image": {
1760
- out += renderer.image(token);
1761
- break;
1762
- }
1763
- case "strong": {
1764
- out += renderer.strong(token);
1765
- break;
1766
- }
1767
- case "em": {
1768
- out += renderer.em(token);
1769
- break;
1770
- }
1771
- case "codespan": {
1772
- out += renderer.codespan(token);
1773
- break;
1774
- }
1775
- case "br": {
1776
- out += renderer.br(token);
1777
- break;
1778
- }
1779
- case "del": {
1780
- out += renderer.del(token);
1781
- break;
1782
- }
1783
- case "text": {
1784
- out += renderer.text(token);
1785
- break;
1786
- }
1787
- default: {
1788
- const errMsg = 'Token with "' + token.type + '" type was not found.';
1789
- if (this.options.silent) {
1790
- console.error(errMsg);
1791
- return "";
1792
- } else {
1793
- throw new Error(errMsg);
1794
- }
1795
- }
1796
- }
1797
- }
1798
- return out;
1799
- }
1800
- }, __name(_e, "__Parser"), _e);
1801
- var _Hooks = (_f = class {
1802
- constructor(options2) {
1803
- __publicField(this, "options");
1804
- __publicField(this, "block");
1805
- this.options = options2 || _defaults;
1806
- }
1807
- /**
1808
- * Process markdown before marked
1809
- */
1810
- preprocess(markdown) {
1811
- return markdown;
1812
- }
1813
- /**
1814
- * Process HTML after marked is finished
1815
- */
1816
- postprocess(html2) {
1817
- return html2;
1818
- }
1819
- /**
1820
- * Process all tokens before walk tokens
1821
- */
1822
- processAllTokens(tokens) {
1823
- return tokens;
1824
- }
1825
- /**
1826
- * Provide function to tokenize markdown
1827
- */
1828
- provideLexer() {
1829
- return this.block ? _Lexer.lex : _Lexer.lexInline;
1830
- }
1831
- /**
1832
- * Provide function to parse tokens
1833
- */
1834
- provideParser() {
1835
- return this.block ? _Parser.parse : _Parser.parseInline;
1836
- }
1837
- }, __name(_f, "_Hooks"), __publicField(_f, "passThroughHooks", /* @__PURE__ */ new Set([
1838
- "preprocess",
1839
- "postprocess",
1840
- "processAllTokens"
1841
- ])), _f);
1842
- var Marked = (_g = class {
1843
- constructor(...args) {
1844
- __publicField(this, "defaults", _getDefaults());
1845
- __publicField(this, "options", this.setOptions);
1846
- __publicField(this, "parse", this.parseMarkdown(true));
1847
- __publicField(this, "parseInline", this.parseMarkdown(false));
1848
- __publicField(this, "Parser", _Parser);
1849
- __publicField(this, "Renderer", _Renderer);
1850
- __publicField(this, "TextRenderer", _TextRenderer);
1851
- __publicField(this, "Lexer", _Lexer);
1852
- __publicField(this, "Tokenizer", _Tokenizer);
1853
- __publicField(this, "Hooks", _Hooks);
1854
- this.use(...args);
1855
- }
1856
- /**
1857
- * Run callback for every token
1858
- */
1859
- walkTokens(tokens, callback) {
1860
- var _a2, _b2;
1861
- let values = [];
1862
- for (const token of tokens) {
1863
- values = values.concat(callback.call(this, token));
1864
- switch (token.type) {
1865
- case "table": {
1866
- const tableToken = token;
1867
- for (const cell of tableToken.header) {
1868
- values = values.concat(this.walkTokens(cell.tokens, callback));
1869
- }
1870
- for (const row of tableToken.rows) {
1871
- for (const cell of row) {
1872
- values = values.concat(this.walkTokens(cell.tokens, callback));
1873
- }
1874
- }
1875
- break;
1876
- }
1877
- case "list": {
1878
- const listToken = token;
1879
- values = values.concat(this.walkTokens(listToken.items, callback));
1880
- break;
1881
- }
1882
- default: {
1883
- const genericToken = token;
1884
- if ((_b2 = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b2[genericToken.type]) {
1885
- this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
1886
- const tokens2 = genericToken[childTokens].flat(Infinity);
1887
- values = values.concat(this.walkTokens(tokens2, callback));
1888
- });
1889
- } else if (genericToken.tokens) {
1890
- values = values.concat(this.walkTokens(genericToken.tokens, callback));
1891
- }
1892
- }
1893
- }
1894
- }
1895
- return values;
1896
- }
1897
- use(...args) {
1898
- const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
1899
- args.forEach((pack) => {
1900
- const opts = { ...pack };
1901
- opts.async = this.defaults.async || opts.async || false;
1902
- if (pack.extensions) {
1903
- pack.extensions.forEach((ext) => {
1904
- if (!ext.name) {
1905
- throw new Error("extension name required");
1906
- }
1907
- if ("renderer" in ext) {
1908
- const prevRenderer = extensions.renderers[ext.name];
1909
- if (prevRenderer) {
1910
- extensions.renderers[ext.name] = function(...args2) {
1911
- let ret = ext.renderer.apply(this, args2);
1912
- if (ret === false) {
1913
- ret = prevRenderer.apply(this, args2);
1914
- }
1915
- return ret;
1916
- };
1917
- } else {
1918
- extensions.renderers[ext.name] = ext.renderer;
1919
- }
1920
- }
1921
- if ("tokenizer" in ext) {
1922
- if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
1923
- throw new Error("extension level must be 'block' or 'inline'");
1924
- }
1925
- const extLevel = extensions[ext.level];
1926
- if (extLevel) {
1927
- extLevel.unshift(ext.tokenizer);
1928
- } else {
1929
- extensions[ext.level] = [ext.tokenizer];
1930
- }
1931
- if (ext.start) {
1932
- if (ext.level === "block") {
1933
- if (extensions.startBlock) {
1934
- extensions.startBlock.push(ext.start);
1935
- } else {
1936
- extensions.startBlock = [ext.start];
1937
- }
1938
- } else if (ext.level === "inline") {
1939
- if (extensions.startInline) {
1940
- extensions.startInline.push(ext.start);
1941
- } else {
1942
- extensions.startInline = [ext.start];
1943
- }
1944
- }
1945
- }
1946
- }
1947
- if ("childTokens" in ext && ext.childTokens) {
1948
- extensions.childTokens[ext.name] = ext.childTokens;
1949
- }
1950
- });
1951
- opts.extensions = extensions;
1952
- }
1953
- if (pack.renderer) {
1954
- const renderer = this.defaults.renderer || new _Renderer(this.defaults);
1955
- for (const prop in pack.renderer) {
1956
- if (!(prop in renderer)) {
1957
- throw new Error(`renderer '${prop}' does not exist`);
1958
- }
1959
- if (["options", "parser"].includes(prop)) {
1960
- continue;
1961
- }
1962
- const rendererProp = prop;
1963
- const rendererFunc = pack.renderer[rendererProp];
1964
- const prevRenderer = renderer[rendererProp];
1965
- renderer[rendererProp] = (...args2) => {
1966
- let ret = rendererFunc.apply(renderer, args2);
1967
- if (ret === false) {
1968
- ret = prevRenderer.apply(renderer, args2);
1969
- }
1970
- return ret || "";
1971
- };
1972
- }
1973
- opts.renderer = renderer;
1974
- }
1975
- if (pack.tokenizer) {
1976
- const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
1977
- for (const prop in pack.tokenizer) {
1978
- if (!(prop in tokenizer)) {
1979
- throw new Error(`tokenizer '${prop}' does not exist`);
1980
- }
1981
- if (["options", "rules", "lexer"].includes(prop)) {
1982
- continue;
1983
- }
1984
- const tokenizerProp = prop;
1985
- const tokenizerFunc = pack.tokenizer[tokenizerProp];
1986
- const prevTokenizer = tokenizer[tokenizerProp];
1987
- tokenizer[tokenizerProp] = (...args2) => {
1988
- let ret = tokenizerFunc.apply(tokenizer, args2);
1989
- if (ret === false) {
1990
- ret = prevTokenizer.apply(tokenizer, args2);
1991
- }
1992
- return ret;
1993
- };
1994
- }
1995
- opts.tokenizer = tokenizer;
1996
- }
1997
- if (pack.hooks) {
1998
- const hooks = this.defaults.hooks || new _Hooks();
1999
- for (const prop in pack.hooks) {
2000
- if (!(prop in hooks)) {
2001
- throw new Error(`hook '${prop}' does not exist`);
2002
- }
2003
- if (["options", "block"].includes(prop)) {
2004
- continue;
2005
- }
2006
- const hooksProp = prop;
2007
- const hooksFunc = pack.hooks[hooksProp];
2008
- const prevHook = hooks[hooksProp];
2009
- if (_Hooks.passThroughHooks.has(prop)) {
2010
- hooks[hooksProp] = (arg) => {
2011
- if (this.defaults.async) {
2012
- return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
2013
- return prevHook.call(hooks, ret2);
2014
- });
2015
- }
2016
- const ret = hooksFunc.call(hooks, arg);
2017
- return prevHook.call(hooks, ret);
2018
- };
2019
- } else {
2020
- hooks[hooksProp] = (...args2) => {
2021
- let ret = hooksFunc.apply(hooks, args2);
2022
- if (ret === false) {
2023
- ret = prevHook.apply(hooks, args2);
2024
- }
2025
- return ret;
2026
- };
2027
- }
2028
- }
2029
- opts.hooks = hooks;
2030
- }
2031
- if (pack.walkTokens) {
2032
- const walkTokens2 = this.defaults.walkTokens;
2033
- const packWalktokens = pack.walkTokens;
2034
- opts.walkTokens = function(token) {
2035
- let values = [];
2036
- values.push(packWalktokens.call(this, token));
2037
- if (walkTokens2) {
2038
- values = values.concat(walkTokens2.call(this, token));
2039
- }
2040
- return values;
2041
- };
2042
- }
2043
- this.defaults = { ...this.defaults, ...opts };
2044
- });
2045
- return this;
2046
- }
2047
- setOptions(opt) {
2048
- this.defaults = { ...this.defaults, ...opt };
2049
- return this;
2050
- }
2051
- lexer(src, options2) {
2052
- return _Lexer.lex(src, options2 ?? this.defaults);
2053
- }
2054
- parser(tokens, options2) {
2055
- return _Parser.parse(tokens, options2 ?? this.defaults);
2056
- }
2057
- parseMarkdown(blockType) {
2058
- const parse2 = /* @__PURE__ */ __name((src, options2) => {
2059
- const origOpt = { ...options2 };
2060
- const opt = { ...this.defaults, ...origOpt };
2061
- const throwError = this.onError(!!opt.silent, !!opt.async);
2062
- if (this.defaults.async === true && origOpt.async === false) {
2063
- return throwError(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."));
2064
- }
2065
- if (typeof src === "undefined" || src === null) {
2066
- return throwError(new Error("marked(): input parameter is undefined or null"));
2067
- }
2068
- if (typeof src !== "string") {
2069
- return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2070
- }
2071
- if (opt.hooks) {
2072
- opt.hooks.options = opt;
2073
- opt.hooks.block = blockType;
2074
- }
2075
- const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
2076
- const parser2 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
2077
- if (opt.async) {
2078
- return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
2079
- }
2080
- try {
2081
- if (opt.hooks) {
2082
- src = opt.hooks.preprocess(src);
2083
- }
2084
- let tokens = lexer2(src, opt);
2085
- if (opt.hooks) {
2086
- tokens = opt.hooks.processAllTokens(tokens);
2087
- }
2088
- if (opt.walkTokens) {
2089
- this.walkTokens(tokens, opt.walkTokens);
2090
- }
2091
- let html2 = parser2(tokens, opt);
2092
- if (opt.hooks) {
2093
- html2 = opt.hooks.postprocess(html2);
2094
- }
2095
- return html2;
2096
- } catch (e) {
2097
- return throwError(e);
2098
- }
2099
- }, "parse2");
2100
- return parse2;
2101
- }
2102
- onError(silent, async) {
2103
- return (e) => {
2104
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2105
- if (silent) {
2106
- const msg = "<p>An error occurred:</p><pre>" + escape2(e.message + "", true) + "</pre>";
2107
- if (async) {
2108
- return Promise.resolve(msg);
2109
- }
2110
- return msg;
2111
- }
2112
- if (async) {
2113
- return Promise.reject(e);
2114
- }
2115
- throw e;
2116
- };
2117
- }
2118
- }, __name(_g, "Marked"), _g);
2119
- var markedInstance = new Marked();
2120
- function marked(src, opt) {
2121
- return markedInstance.parse(src, opt);
2122
- }
2123
- __name(marked, "marked");
2124
- marked.options = marked.setOptions = function(options2) {
2125
- markedInstance.setOptions(options2);
2126
- marked.defaults = markedInstance.defaults;
2127
- changeDefaults(marked.defaults);
2128
- return marked;
2129
- };
2130
- marked.getDefaults = _getDefaults;
2131
- marked.defaults = _defaults;
2132
- marked.use = function(...args) {
2133
- markedInstance.use(...args);
2134
- marked.defaults = markedInstance.defaults;
2135
- changeDefaults(marked.defaults);
2136
- return marked;
2137
- };
2138
- marked.walkTokens = function(tokens, callback) {
2139
- return markedInstance.walkTokens(tokens, callback);
2140
- };
2141
- marked.parseInline = markedInstance.parseInline;
2142
- marked.Parser = _Parser;
2143
- marked.parser = _Parser.parse;
2144
- marked.Renderer = _Renderer;
2145
- marked.TextRenderer = _TextRenderer;
2146
- marked.Lexer = _Lexer;
2147
- marked.lexer = _Lexer.lex;
2148
- marked.Tokenizer = _Tokenizer;
2149
- marked.Hooks = _Hooks;
2150
- marked.parse = marked;
2151
- marked.options;
2152
- marked.setOptions;
2153
- marked.use;
2154
- marked.walkTokens;
2155
- marked.parseInline;
2156
- _Parser.parse;
2157
- _Lexer.lex;
2158
- export {
2159
- _Hooks as Hooks,
2160
- _Lexer as Lexer,
2161
- Marked,
2162
- _Parser as Parser,
2163
- _Renderer as Renderer,
2164
- _TextRenderer as TextRenderer,
2165
- _Tokenizer as Tokenizer,
2166
- _defaults as defaults,
2167
- _getDefaults as getDefaults,
2168
- marked
2169
- };