micromark / micromark-extension-gfm-table

micromark extension to support GFM tables
https://unifiedjs.com
MIT License
6 stars 6 forks source link

Parsing fails when newline characters are present #2

Closed EvHaus closed 3 years ago

EvHaus commented 3 years ago

Initial checklist

Affected packages and versions

micromark-extension-gfm-table@^1.0.0

Link to runnable example

https://codesandbox.io/s/remark-debug-forked-q95c5?file=/src/index.js

Steps to reproduce

Feed the following markdown into remark-gfm:

- [x] Task 1

or to be more clear (note the whitespace):

- [x] Task 1\n    

I can't quite figure out the exact condition for this. Seems like the presence of a line break (\n) somewhere in the input causes the crash. At the end -- definitely crash. At the start -- sometimes crash.

Expected behavior

Properly parsed response, ie. * Task 1

Actual behavior

micromark-extension-gfm-table crashes with TypeError: Cannot read property '3' of undefined.

Full stack trace:

syntax.js:587 Uncaught TypeError: Cannot read property '3' of undefined
    at lineStart (syntax.js:587)
    at go (create-tokenizer.js:136)
    at main (create-tokenizer.js:127)
    at Object.write (create-tokenizer.js:70)
    at continueFlow (document.js:119)
    at flowContinue (document.js:91)
    at go (create-tokenizer.js:136)
    at main (create-tokenizer.js:130)
    at Object.write (create-tokenizer.js:70)
    at fromMarkdown (index.js:26)

Failing line:

    function lineStart(code) {
      return self.parser.lazy[self.now().line] ? nok(code) : ok(code)
    }

Runtime

Google Chrome

Package manager

yarn v1

OS

macOS

Build and bundle tools

Webpack

wooorm commented 3 years ago

Make sure to update all the remark deps. Could you check if that works?

EvHaus commented 3 years ago

Thanks for the super fast response. Yeah, the problem was that I was using remark 12. Upgrading to 14.0.1 fixed the issue. 👍

Could you please update the version in the CodeSandbox template in the issue template? That would have helped me catch the issue. I was lucky that the CodeSandbox version was as outdated as my local project :)

github-actions[bot] commented 3 years ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

wooorm commented 3 years ago

Perf!

I’ve updated everything I’ve got access to. Maybe @ChristianMurphy has some more sandboxes that can be updated?

ChristianMurphy commented 3 years ago

The main three are in the issue template/issue form.