marked 14.0.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/marked.cjs +22 -6
- package/lib/marked.cjs.map +1 -1
- package/lib/marked.d.cts +12 -49
- package/lib/marked.d.ts +12 -49
- package/lib/marked.esm.js +22 -6
- package/lib/marked.esm.js.map +1 -1
- package/lib/marked.umd.js +22 -6
- package/lib/marked.umd.js.map +1 -1
- package/man/marked.1 +1 -1
- package/marked.min.js +2 -2
- package/package.json +9 -9
package/lib/marked.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* marked v14.
|
|
2
|
+
* marked v14.1.0 - a markdown parser
|
|
3
3
|
* Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
|
|
4
4
|
* https://github.com/markedjs/marked
|
|
5
5
|
*/
|
|
@@ -2082,6 +2082,7 @@
|
|
|
2082
2082
|
|
|
2083
2083
|
class _Hooks {
|
|
2084
2084
|
options;
|
|
2085
|
+
block;
|
|
2085
2086
|
constructor(options) {
|
|
2086
2087
|
this.options = options || exports.defaults;
|
|
2087
2088
|
}
|
|
@@ -2108,13 +2109,25 @@
|
|
|
2108
2109
|
processAllTokens(tokens) {
|
|
2109
2110
|
return tokens;
|
|
2110
2111
|
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Provide function to tokenize markdown
|
|
2114
|
+
*/
|
|
2115
|
+
provideLexer() {
|
|
2116
|
+
return this.block ? _Lexer.lex : _Lexer.lexInline;
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Provide function to parse tokens
|
|
2120
|
+
*/
|
|
2121
|
+
provideParser() {
|
|
2122
|
+
return this.block ? _Parser.parse : _Parser.parseInline;
|
|
2123
|
+
}
|
|
2111
2124
|
}
|
|
2112
2125
|
|
|
2113
2126
|
class Marked {
|
|
2114
2127
|
defaults = _getDefaults();
|
|
2115
2128
|
options = this.setOptions;
|
|
2116
|
-
parse = this.parseMarkdown(
|
|
2117
|
-
parseInline = this.parseMarkdown(
|
|
2129
|
+
parse = this.parseMarkdown(true);
|
|
2130
|
+
parseInline = this.parseMarkdown(false);
|
|
2118
2131
|
Parser = _Parser;
|
|
2119
2132
|
Renderer = _Renderer;
|
|
2120
2133
|
TextRenderer = _TextRenderer;
|
|
@@ -2287,8 +2300,8 @@
|
|
|
2287
2300
|
if (!(prop in hooks)) {
|
|
2288
2301
|
throw new Error(`hook '${prop}' does not exist`);
|
|
2289
2302
|
}
|
|
2290
|
-
if (
|
|
2291
|
-
// ignore options
|
|
2303
|
+
if (['options', 'block'].includes(prop)) {
|
|
2304
|
+
// ignore options and block properties
|
|
2292
2305
|
continue;
|
|
2293
2306
|
}
|
|
2294
2307
|
const hooksProp = prop;
|
|
@@ -2346,7 +2359,7 @@
|
|
|
2346
2359
|
parser(tokens, options) {
|
|
2347
2360
|
return _Parser.parse(tokens, options ?? this.defaults);
|
|
2348
2361
|
}
|
|
2349
|
-
parseMarkdown(
|
|
2362
|
+
parseMarkdown(blockType) {
|
|
2350
2363
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2351
2364
|
const parse = (src, options) => {
|
|
2352
2365
|
const origOpt = { ...options };
|
|
@@ -2366,7 +2379,10 @@
|
|
|
2366
2379
|
}
|
|
2367
2380
|
if (opt.hooks) {
|
|
2368
2381
|
opt.hooks.options = opt;
|
|
2382
|
+
opt.hooks.block = blockType;
|
|
2369
2383
|
}
|
|
2384
|
+
const lexer = opt.hooks ? opt.hooks.provideLexer() : (blockType ? _Lexer.lex : _Lexer.lexInline);
|
|
2385
|
+
const parser = opt.hooks ? opt.hooks.provideParser() : (blockType ? _Parser.parse : _Parser.parseInline);
|
|
2370
2386
|
if (opt.async) {
|
|
2371
2387
|
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
|
|
2372
2388
|
.then(src => lexer(src, opt))
|