Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when handling a Table node when converting to markdown #161

Closed
dannyob opened this issue Sep 26, 2023 · 2 comments
Closed

Error when handling a Table node when converting to markdown #161

dannyob opened this issue Sep 26, 2023 · 2 comments

Comments

@dannyob
Copy link

dannyob commented Sep 26, 2023

Environment

  • Operating System: Linux 6.1.0-10-amd64 Debian 6.1.38-2 (2023-07-27) x86_64 GNU/Linux
  • node --version: v18.13.0
  • npm --version: 9.2.0
  • yarn --version, if using Yarn:
  • percollate --version: 4.0.2

Description

Hi! My percollate currently falls over on sites like Wikipedia when converting to Markdown:

: workboat  ~%; percollate md 'https://en.wikipedia.org/wiki/Danny_O%27Brien_(journalist)'                       
Fetching: https://en.wikipedia.org/wiki/Danny_O%27Brien_(journalist) ✓
Enhancing web page: https://en.wikipedia.org/wiki/Danny_O%27Brien_(journalist) ✓
file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/index.js:113
  throw new Error('Cannot handle unknown node `' + node.type + '`')
        ^

Error: Cannot handle unknown node `table`
    at Object.unknown (file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/index.js:113:9)
    at Object.one [as handle] (file:///usr/local/lib/node_modules/percollate/node_modules/zwitch/index.js:108:17)
    at containerFlow (file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/util/container-flow.js:36:15)
    at Object.containerFlowBound [as containerFlow] (file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/index.js:158:10)
    at Object.root (file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/handle/root.js:22:13)
    at Object.one [as handle] (file:///usr/local/lib/node_modules/percollate/node_modules/zwitch/index.js:108:17)
    at toMarkdown (file:///usr/local/lib/node_modules/percollate/node_modules/mdast-util-to-markdown/lib/index.js:71:22)
    at bundleMd (file:///usr/local/lib/node_modules/percollate/index.js:647:13)
    at async generate (file:///usr/local/lib/node_modules/percollate/index.js:710:3)
    at async md (file:///usr/local/lib/node_modules/percollate/index.js:758:9)

Node.js v18.13.0
: workboat  ~%;

I think this is because the mdast markdown conversion only supports table with the help of another npm module: see syntax-tree/mdast-util-to-markdown#1

@danburzo
Copy link
Owner

Good catch, @dannyob! We were already supposed to be using mdast-util-gfm, but there was a small typo that prevented it from being used.

@danburzo
Copy link
Owner

Fixed in percollate@4.0.3.

Looking at the provided test case I can see potential problems with the way the whole remark pipeline takes the HTML verbatim and stringifies it to Markdown in ways that might trip some Markdown parsers, especially around <i><a></a></i>, so that might warrant further attention.

But the issue at hand should be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants