Remark: Failed to render preview: +0ms Error: Incorrectly eaten value

Created on 21 Dec 2020  路  4Comments  路  Source: remarkjs/remark

Subject of the issue

I am using a tokenizer for remark and hitting this issue.

Your environment

  • OS: Mac OS 10.15.x
  • Packages: This is remark inside of Inkdrop.
  • Env: Electron 7.3.2 (Inkdrop app)

Steps to reproduce

When running this package at this commit:
https://github.com/ryanpcmcquen/inkdrop_wiki_links/commit/9f296f6962723f05c530927b2c53256997644454

Changing the regex from:

const RE_WIKI = /\[([^\]]+)\]{2}/gm;

To:

const RE_WIKI = /\[([^\[\]]+)\]{2}/gm;

Brings out the error seen below.

Expected behavior

Values would be parsed.

Actual behavior

app:error Failed to render preview: +0ms Error: Incorrectly eaten value: please report this warning on https://git.io/vg5Ft
    at validateEat (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/tokenizer.js:151:17)
    at eat (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/tokenizer.js:236:13)
    at Of.tokenizer (/Users/ry/code/inkdrop_wiki_links/lib/wiki_link_parser.js:25:20)
    at Of.tokenize [as tokenizeInline] (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/tokenizer.js:62:24)
    at Of.paragraph (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/tokenize/paragraph.js:96:26)
    at Of.tokenize [as tokenizeBlock] (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/tokenizer.js:62:24)
    at Of.parse (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/remark-parse/lib/parse.js:33:26)
    at Function.parse (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/unified/index.js:281:51)
    at pipelineParse (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/unified/index.js:23:22)
    at wrapped (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/trough/wrap.js:25:25)
    at next (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/trough/index.js:57:30)
    at Object.run (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/trough/index.js:31:16)
    at executor (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/unified/index.js:375:22)
    at Function.process (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/unified/index.js:370:11)
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/browser-exports.js:1:7012
    at new Promise (<anonymous>)
    at f.render (/Applications/Inkdrop.app/Contents/Resources/app.asar/browser-exports.js:1:6990)
    at file:///Applications/Inkdrop.app/Contents/Resources/app.asar/browser-commons.js:1:60256
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/redux-thunk/lib/index.js:11:24
    at Object.dispatch (file:///Applications/Inkdrop.app/Contents/Resources/app.asar/browser-main.js:4:559855)
    at file:///Applications/Inkdrop.app/Contents/Resources/app.asar/browser-main.js:4:155538
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/lodash/lodash.js:2750:49
    at __trace__ (/Applications/Inkdrop.app/Contents/Resources/app.asar/app/static/node_modules/@bugsnag/browser/dist/bugsnag.js:2231:34)
馃憖 areexternal 馃 statuwaiting

Most helpful comment

Hi there!

This is not a remark bug. This is a bug in the plugin you鈥檙e making. It鈥檚 surfacing in remark, because it doesn鈥檛 know what to do with it. The bug is that you鈥檙e supposed to tokenize something at the start of value, and not tokenize when it鈥檚 somewhere else in the document, but your regex is global so that鈥檚 probably happening.

We鈥檙e on a new parser now though, so I wouldn鈥檛 put much time in making something for an older version.
And this looks like remark-wiki-links as you say, which had a version for the old parser, and is already updated to support the new parser.
I鈥檇 suggest using that instead!

All 4 comments

@ryanpcmcquen sorry you ran into some trouble, a few questions and thoughts:

  • what version of remark is inkdrop using?
  • given that this is coming from a plugin, this is most likely a bug in the plugin causing values to be eaten crashing remark core, rather than a bug in remark core itself. For support creating plugins https://github.com/remarkjs/remark/discussions is a better place than issues.
  • This looks a lot like https://github.com/djm/remark-shortcodes, have you considered using that directly? Or is there a difference in syntax?

@ChristianMurphy, got the versions:

    "unified": "^9.2.0",
    "remark-parse": "^8.0.3",
    "remark-rehype": "^7.0.0",

I can move this to discussions. Shortcodes are meant to expand where I actually want linking functionality, plus they seem intended for blocks while I probably want _only_ inline parsing.

But, there is this that I could look into:

https://github.com/landakram/remark-wiki-link

Hi there!

This is not a remark bug. This is a bug in the plugin you鈥檙e making. It鈥檚 surfacing in remark, because it doesn鈥檛 know what to do with it. The bug is that you鈥檙e supposed to tokenize something at the start of value, and not tokenize when it鈥檚 somewhere else in the document, but your regex is global so that鈥檚 probably happening.

We鈥檙e on a new parser now though, so I wouldn鈥檛 put much time in making something for an older version.
And this looks like remark-wiki-links as you say, which had a version for the old parser, and is already updated to support the new parser.
I鈥檇 suggest using that instead!

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fisker picture fisker  路  4Comments

niftylettuce picture niftylettuce  路  4Comments

niksurff picture niksurff  路  4Comments

soroushm picture soroushm  路  6Comments

renekliment picture renekliment  路  5Comments