marked 9.1.4 → 9.1.6

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.d.cts CHANGED
@@ -435,11 +435,9 @@ export declare class Marked {
435
435
  parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
436
436
  parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
437
437
  Parser: typeof _Parser;
438
- parser: typeof _Parser.parse;
439
438
  Renderer: typeof _Renderer;
440
439
  TextRenderer: typeof _TextRenderer;
441
440
  Lexer: typeof _Lexer;
442
- lexer: typeof _Lexer.lex;
443
441
  Tokenizer: typeof _Tokenizer;
444
442
  Hooks: typeof _Hooks;
445
443
  constructor(...args: MarkedExtension[]);
@@ -449,6 +447,8 @@ export declare class Marked {
449
447
  walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
450
448
  use(...args: MarkedExtension[]): this;
451
449
  setOptions(opt: MarkedOptions): this;
450
+ lexer(src: string, options?: MarkedOptions): TokensList;
451
+ parser(tokens: Token[], options?: MarkedOptions): string;
452
452
  }
453
453
  /**
454
454
  * Compiles markdown to HTML asynchronously.
package/lib/marked.d.ts CHANGED
@@ -435,11 +435,9 @@ export declare class Marked {
435
435
  parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
436
436
  parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
437
437
  Parser: typeof _Parser;
438
- parser: typeof _Parser.parse;
439
438
  Renderer: typeof _Renderer;
440
439
  TextRenderer: typeof _TextRenderer;
441
440
  Lexer: typeof _Lexer;
442
- lexer: typeof _Lexer.lex;
443
441
  Tokenizer: typeof _Tokenizer;
444
442
  Hooks: typeof _Hooks;
445
443
  constructor(...args: MarkedExtension[]);
@@ -449,6 +447,8 @@ export declare class Marked {
449
447
  walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
450
448
  use(...args: MarkedExtension[]): this;
451
449
  setOptions(opt: MarkedOptions): this;
450
+ lexer(src: string, options?: MarkedOptions): TokensList;
451
+ parser(tokens: Token[], options?: MarkedOptions): string;
452
452
  }
453
453
  /**
454
454
  * Compiles markdown to HTML asynchronously.
package/lib/marked.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v9.1.4 - a markdown parser
2
+ * marked v9.1.6 - a markdown parser
3
3
  * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -749,7 +749,7 @@ class _Tokenizer {
749
749
  const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
750
750
  endReg.lastIndex = 0;
751
751
  // Clip maskedSrc to same section of string as src (move to lexer?)
752
- maskedSrc = maskedSrc.slice(-1 * src.length + match[0].length - 1);
752
+ maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
753
753
  while ((match = endReg.exec(maskedSrc)) != null) {
754
754
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
755
755
  if (!rDelim)
@@ -770,7 +770,9 @@ class _Tokenizer {
770
770
  continue; // Haven't found enough closing delimiters
771
771
  // Remove extra characters. *a*** -> *a*
772
772
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
773
- const raw = [...src].slice(0, lLength + match.index + rLength + 1).join('');
773
+ // char length can be >1 for unicode characters;
774
+ const lastCharLength = [...match[0]][0].length;
775
+ const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
774
776
  // Create `em` if smallest delimiter has odd char count. *a***
775
777
  if (Math.min(lLength, rLength) % 2) {
776
778
  const text = raw.slice(1, -1);
@@ -2048,11 +2050,9 @@ class Marked {
2048
2050
  parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
2049
2051
  parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
2050
2052
  Parser = _Parser;
2051
- parser = _Parser.parse;
2052
2053
  Renderer = _Renderer;
2053
2054
  TextRenderer = _TextRenderer;
2054
2055
  Lexer = _Lexer;
2055
- lexer = _Lexer.lex;
2056
2056
  Tokenizer = _Tokenizer;
2057
2057
  Hooks = _Hooks;
2058
2058
  constructor(...args) {
@@ -2249,6 +2249,12 @@ class Marked {
2249
2249
  this.defaults = { ...this.defaults, ...opt };
2250
2250
  return this;
2251
2251
  }
2252
+ lexer(src, options) {
2253
+ return _Lexer.lex(src, options ?? this.defaults);
2254
+ }
2255
+ parser(tokens, options) {
2256
+ return _Parser.parse(tokens, options ?? this.defaults);
2257
+ }
2252
2258
  #parseMarkdown(lexer, parser) {
2253
2259
  return (src, options) => {
2254
2260
  const origOpt = { ...options };