I am using unified(), remark-directive and remark-parse to convert Markdown to HTML and I can successfully convert the most of the Markdown but the markdown format below is being ignored. I am aware of the following markdown pattern [Anchor Link Text](https://test.com) for the anchor tag which works fine. Anyone has come across this pattern? I am looking any unified plugins that can help with this without any luck.
:a[Anchor Link Text]{href='https://www.testurl.com/movies/news/the-url-to-test'}
The syntax looks like the Generic Directives Proposal.
In the
remark-directivedocumentation under API, it notes that the plugin parses the directives for the syntax tree (likecontainerDirective,leafDirective,textDirective, etc.). The plugin doesn't handle implementing/transforming the directives and a developer needs to implement their own plugin to handle the directives. Because directives are generic and not standardized, there likely isn't a premade plugin for each project's unique implementation.The custom plugin
myRemarkPluginexample in theremark-directiveUsesection may conveniently cover your use case.The function
myRemarkPlugincreates a tag with the same name as the:aand properties from{}. In the desired case, replacing an:awith an HTML tagaand the directive key/values{href="#"}are the HTML tag props fits that implementation.It will transform any
:::or::or:directives to an HTML tag of the same name, so tweak the logic for your requirements. If there are other directive replacement patterns, those need to be handled with their own logic.Useexample pulled fromremark-directiveGitHub:The implementation with the custom plugin transforms
into
And should transform
into