electron / hubdown

Convert markdown to GitHub-style HTML using a common set of remark plugins
MIT License
39 stars 23 forks source link

remark-heading-id extension not used when run before remark processor #39

Closed rachmari closed 2 years ago

rachmari commented 3 years ago

@wooorm Zeke forwarded me to you as the maintainer of remark and the Unified.js ecosystem. The docs provided for Unified.js are excellent! πŸ™Œ I'm testing out adding an extension and also looking at writing a new extension, and I'm running into some issues. Can you confirm if this is a bug in the extension or hubdown?

I'm testing out the remark-heading-id extension and it seems that the placement of the extension in the runBefore list determines whether it works or not.

When the remark-heading-id extension is listed first in this pull request, the extension works:

Screen Shot 2021-01-11 at 9 17 52 PM

When it's not listed first, the custom id is rendered as part of the heading:

Screen Shot 2021-01-11 at 9 18 12 PM
wooorm commented 3 years ago

Hi Rachael! Thank you :)

remark-heading-id is a community project, so it could definitely be a bug there. From a glance at the code though, it looks fine.

runbefore is a hubdown option, so that’s more a thing for @zeke. However, from a glance at the code it seems that runbefore should be an array of things: where each thing is either a single plugin, or an array where the first thing is a plugin, and the second the options. That leads me to believe that the following might work:

      runBefore: [
        [remarkCodeExtra, { transform: codeHeader }],
        remarkHeadingId
      ]
rachmari commented 3 years ago

@wooorm thank you so much! This is super helpful. I'm very new to the Unified.js ecosystem. πŸ™‡β€β™€οΈ I'll give that a try!