TrialAndErrorOrg / parsers

Monorepo for a suite of `unified`-compatible converters for converting between, from, and to .docx, JATS XML, LaTeX, and PDF
https://convert.centeroftrialanderror.com
GNU General Public License v3.0
15 stars 0 forks source link

[rehype-notion] TypeError: state.createTracker is not a function #94

Closed suupic closed 1 year ago

suupic commented 1 year ago
The extension "gfmToMarkdown" is unable to handle the <li> tag correctly. 
If <li> appears on the page, it will trigger an error:
TypeError: state.createTracker is not a function
    at listItem (file:///project_path/node_modules/mdast-util-to-markdown/lib/handle/list-item.js:47:25)
    at Object.listItemWithTaskListItem (file:///project_path/node_modules/mdast-util-gfm-task-list-item/lib/index.js:125:15)
    at Object.one [as handle] (file:///project_path/node_modules/zwitch/index.js:108:17)
    at containerFlow (file:///project_path/node_modules/rehype-notion/node_modules/mdast-util-to-markdown/lib/util/container-flow.js:34:17)
    at Object.list (file:///project_path/node_modules/rehype-notion/node_modules/mdast-util-to-markdown/lib/handle/list.js:112:17)
    at Object.one [as handle] (file:///project_path/node_modules/zwitch/index.js:108:17)
    at containerFlow (file:///project_path/node_modules/rehype-notion/node_modules/mdast-util-to-markdown/lib/util/container-flow.js:34:17)
    at Object.root (file:///project_path/node_modules/rehype-notion/node_modules/mdast-util-to-markdown/lib/handle/root.js:20:10)
    at Object.one [as handle] (file:///project_path/node_modules/zwitch/index.js:108:17)
    at toMarkdown (file:///project_path/node_modules/rehype-notion/node_modules/mdast-util-to-markdown/lib/index.js:45:24)

Here is an example:

import { unified } from "unified";
import rehypeParse from "rehype-parse";
import rehypeToNotion from "rehype-notion";

const html = `
hello
<ul>
<li>1</li>
</ul>
`;
const notionBlocks = await unified()
  .use(rehypeParse, { fragment: false })
  .use(rehypeToNotion, {})
  .processSync(html).result;

console.log(notionBlocks);
tefkah commented 1 year ago

Hmm strange. Thanks for reporting this!

I don't know what exactly caused this issue (did not run into it on dev) but I can reproduce it on 0.1.2

I just pushed a fix which seems to fix it! Could you try updating to 0.1.3?

suupic commented 1 year ago

@tefkah I updated to 0.1.3 and it works fine, thank you