Skip to content

marked@2.0.0 throws SyntaxError: Invalid regular expression #1937

Description

@wickedest

Marked version:
2.0.0

Describe the bug
Markdown that worked previously, now errors with: SyntaxError: Invalid regular expression: /[\p{L}\p{N}]/: Invalid escape

To Reproduce

  1. Install marked npm install --save marked@2.0.0
  2. Create index.js:
const marked = require('marked');
const text = 'one _expectem_\ntwo _expect__em_\nthree _expect__another__em_\n';
console.log(marked(text));
  1. node index.js
SyntaxError: Invalid regular expression: /[\p{L}\p{N}]/: Invalid escape
Please report this to https://github.com/markedjs/marked.
    at Tokenizer.emStrong (/home/example/node_modules/marked/src/Tokenizer.js:534:30)
    at Lexer.inlineTokens (/home/example/node_modules/marked/src/Lexer.js:418:34)
    at Lexer.inline (/home/example/node_modules/marked/src/Lexer.js:282:16)
    at Lexer.lex (/home/example/node_modules/marked/src/Lexer.js:114:10)
    at Function.lex (/home/example/node_modules/marked/src/Lexer.js:93:18)
    at marked (/home/example/node_modules/marked/src/marked.js:106:26)
    at Object.<anonymous> (/home/example/index.js:3:13)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)

With marked@1.2.9, this works. With marked@2.0.0, errors as above. Also, this happens on node-8. However, node-12 didn't have this issue. Possibly related to #1927.

Expected behavior
Expected previous markdown to work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions