ije/md4w

JSON parse error with `mdToJSON` on commonamrk

Closed this issue · 1 comments

pi0 commented

reproduction:

import { init, mdToJSON } from 'md4w'

const commonMark = await fetch('https://github.com/ije/md4w/raw/main/test/commonmark-spec.md').then(r => r.text())

await init()

try {
  console.log(mdToJSON(commonMark))
} catch (error) {
  console.error(error.stack.slice(0, 200))
}
\Error: Failed to parse JSON: Bad escaped character in JSON at position 4959
[{"type":5},{"type":9,"children":["title: CommonMark Spec","\n","author: John MacFarlane","\n","version: '0.31.2'","\n","data
pi0 commented

Dump: https://gist.github.com/pi0/fb73e2645644319fc30ea87949c47f3a

image

(it seems with JSON method we need to escape some chars)