nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.07k stars 622 forks source link

Give option to set parsing order of Remark Plugins #1445

Open ManasMadrecha opened 2 years ago

ManasMadrecha commented 2 years ago

Is your feature request related to a problem? Please describe

Issue encountered in https://github.com/Atinux/content-wind/issues/6#issuecomment-1213299468

Currently, the remark-mdc plugin is parsed first, and then any other custom plugin.

This happens even when in nuxt.config.ts:

markdown: {
    remarkPlugins: ['custom-plugin', '@docus/remark-mdc'],
    mdc: false
}

Note: Here, '@docus/remark-mdc' is manually added last in remarkPlugins array. Still, it is parsed first.

So, this markdown

becomes

With MDC enabled (by default) ![image](https://user-images.githubusercontent.com/65993481/184408537-52e29204-c930-4c0d-9003-b6e5fee52db2.png)
With MDC disabled ![image](https://user-images.githubusercontent.com/65993481/184408982-fb5f85b7-3e22-433c-ad0c-faffc532eb2b.png)

So, inside the custom remark plugin, it becomes difficult to target [[... type of text, e.g., wiki-links or ![[..., e.g., embed/attachments/transclusions.

So, the issue is I can either use my custom plugin or the remark-mdc, but not both together.

Describe the solution you'd like

The Module should parse the remark plugins based on the order they are present in the array of remarkPlugins. Don't give priority to mdc plugin. Parse it as last remark plugin.

Describe alternatives you've considered

Disable mdc, i.e., set it to false. Then, use the custom remark plugin. But this prevents me from using mdc at all.

Additional context

atinux commented 2 years ago

Thanks for your issue @ManasMadrecha

I think that MDC should ignore the [[ or ![[ syntax directly ☺️

farnabaz commented 2 years ago

Fixed in remark-mdc package and soon will be available on the edge channel

ManasMadrecha commented 1 year ago

@farnabaz @Atinux Not yet fixed in edge channel. The remark-mdc doesn't ignore the [[ or ![[ which makes it very difficult to convert them to links using custom-plugin. It still converts them into span.

Kindly reopen the issue.