(e)
| 2108 | return b.parse(e, t ?? this.defaults); |
| 2109 | } |
| 2110 | parseMarkdown(e) { |
| 2111 | return (n, s) => { |
| 2112 | let i = { ...s }, |
| 2113 | r = { ...this.defaults, ...i }, |
| 2114 | o = this.onError(!!r.silent, !!r.async); |
| 2115 | if (this.defaults.async === !0 && i.async === !1) |
| 2116 | return o( |
| 2117 | new Error( |
| 2118 | "marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.", |
| 2119 | ), |
| 2120 | ); |
| 2121 | if (typeof n > "u" || n === null) |
| 2122 | return o( |
| 2123 | new Error("marked(): input parameter is undefined or null"), |
| 2124 | ); |
| 2125 | if (typeof n != "string") |
| 2126 | return o( |
| 2127 | new Error( |
| 2128 | "marked(): input parameter is of type " + |
| 2129 | Object.prototype.toString.call(n) + |
| 2130 | ", string expected", |
| 2131 | ), |
| 2132 | ); |
| 2133 | r.hooks && ((r.hooks.options = r), (r.hooks.block = e)); |
| 2134 | let a = r.hooks ? r.hooks.provideLexer() : e ? x.lex : x.lexInline, |
| 2135 | c = r.hooks ? r.hooks.provideParser() : e ? b.parse : b.parseInline; |
| 2136 | if (r.async) |
| 2137 | return Promise.resolve(r.hooks ? r.hooks.preprocess(n) : n) |
| 2138 | .then((p) => a(p, r)) |
| 2139 | .then((p) => (r.hooks ? r.hooks.processAllTokens(p) : p)) |
| 2140 | .then((p) => |
| 2141 | r.walkTokens |
| 2142 | ? Promise.all(this.walkTokens(p, r.walkTokens)).then(() => p) |
| 2143 | : p, |
| 2144 | ) |
| 2145 | .then((p) => c(p, r)) |
| 2146 | .then((p) => (r.hooks ? r.hooks.postprocess(p) : p)) |
| 2147 | .catch(o); |
| 2148 | try { |
| 2149 | r.hooks && (n = r.hooks.preprocess(n)); |
| 2150 | let p = a(n, r); |
| 2151 | (r.hooks && (p = r.hooks.processAllTokens(p)), |
| 2152 | r.walkTokens && this.walkTokens(p, r.walkTokens)); |
| 2153 | let u = c(p, r); |
| 2154 | return (r.hooks && (u = r.hooks.postprocess(u)), u); |
| 2155 | } catch (p) { |
| 2156 | return o(p); |
| 2157 | } |
| 2158 | }; |
| 2159 | } |
| 2160 | onError(e, t) { |
| 2161 | return (n) => { |
| 2162 | if ( |
no test coverage detected