Description
I'm working on a project that introduces new syntax to markdown and need to convert that syntax between markdown & html.
This remark-bracketed-spans plugin is a good example of the type of thing I'm working on: https://github.com/sethvincent/remark-bracketed-spans/blob/master/index.js
With that plugin the goal is to convert between:
[text in the span]{.class .other-class key=val another=example}
and:
<p><span class="class other-class" data-key="val" data-another="example">text in the span</span></p>
There are a few similar plugins that I'm working on.
For converting the html to markdown, I'm not sure yet where in the pipeline is best for handling these special cases.
Passing custom handlers as options to this module could take care of it.
Usage would be similar to passing visitors to remark-stringify, and could look like:
var md = unified()
.use(rehypeParse)
.use(rehype2remark, { handlers: handlers }) // passing options through rehype-remark
.use(remarkStringify)
.process(html, options)
var handlers = {
span: function (node, parent) {
// handle conversion
}
}
I can write up a PR for this, but wanted to check to see if there are other approaches I might consider.