Skip to content

Don't break when parsing html in strings in a highlighted codeblock #95

Open
@earlAchromatic

Description

@earlAchromatic

For instance, this (from Notion, codeblock in a toggle) breaks the render very badly:
image

The culprit is here (the blocks html parser):

_mixedHTML(mixedHtml: string) {
    return mixedHtml.replaceAll(/[^<>]+?(?=<\/)/g, (match) => {
      // Must trim or Marked classifies text preceded by tabs as indented code.
      const tokens = marked.lexer(_.trim(match), this.markedOptions)
      return marked.parser(tokens, this.markedOptions)
    })

We could fix our regex or add a condition to avoid anything inside of a set of double quotes. This wouldn't be mixed html, but would just be a string representation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions