ije / md4w

A Markdown renderer written in Zig & C, compiled to WebAssymbly.
MIT License
58 stars 0 forks source link

JSON parse error with `mdToJSON` on commonamrk #5

Closed pi0 closed 6 months ago

pi0 commented 6 months ago

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 6 months ago

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

image

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