benrbray / remark-cite

Adds support for pandoc-style citations to the Markdown syntax for the remark and micromark parsers.
MIT License
20 stars 5 forks source link

Export citePlugin as default #2

Closed benjamineskola closed 1 month ago

benjamineskola commented 2 years ago

This seems to fix #1 by exporting a default method.

I've also ensured options is set, because otherwise I got an exception:

  1:1  error  TypeError: Cannot read property 'syntax' of undefined
    at Function.citePlugin (/Users/ben/Code/remark-cite/remark-cite/dist/index.cjs.js:21:72)
…

I'm not sure if there's a better way of writing that — I've never used typescript before.

benrbray commented 2 years ago

Thanks for the PR! I tried testing this locally with remark-cli (by installing remark-cli alongside remark-cite in a project, but replacing the @benrbray/remark-cite version string in package.json with the path to my local copy of your fork).

Were you able to successfully test this locally? What was your setup?

benrbray commented 2 years ago

Also as a side note: I think this will be a breaking change to the package since it changes how the citePlugin needs to be imported (as a default rather than named export). So I will need to bump the major version. I don't mind doing this as long as it does indeed fix the issue with remark-cli.

benjamineskola commented 2 years ago

I ran this locally by doing npm run build then npm install -g, and I was able to confirm that my …/node_modules/@benrbray/remark-cite/dist/index.*.js had the changes applied.

Then I was able to run remark test.md as normal and see first of all that in debug mode the extension was listed as being loaded (when it hadn't previously), and secondly that the output was as expected (citation nodes in the AST output, preserved citations in the markdown output).

benrbray commented 1 month ago

remark-cite now has a default export, so I believe this issue is resolved. Let me know if that's not the case!