Playing around with https://github.com/wooorm/retext-smartypants and Remark where I visit every text node and run it through smartypants. This works more-or-less but it'll miss converting quotes that are split into separate text nodes...
Thoughts?
Also it's not crazy performant as it's running retext a gazillion times.
I unfortunately have no idea how to properly do that, with retext, currently.
It鈥檚 possible for the markdown tree to be converted to a natural language tree, through remark-retext. This keeps positional info intact, and strips the syntax. Thus making it possible for, say, [retext-spell][https://github.com/wooorm/retext-spell] to detect ex*em*ple as misspelt and suggest example instead.
That three can also be properly modified by retext-smartypants.
However, theres no way to merge that tree back into the markdown tree. And I鈥檓 not sure how to do it.
Say, staying with the earlier example, retext-spell autocorrected ex**em**ple to example. What happens with the strong node? There鈥檚 probably ways to deal with that. Prosemirror deals with similar problems, and things like React or virtual-dom of course. But I鈥檓 not entirely sure where to start.
馃槵
Thought about this a short while, we probably need:
unist-diff](https://github.com/syntax-tree/unist-diff) (Array.<Patch> = diff(Node, Node))unist-patch (patch(Node, Array.<Patch>))mdast-util-patch-from-nlcst (Array.<Patch> = patchFromNLCST(Node, Array.<Patch>))the diff and patch would be ok, but changing nlcst patches to mdast patches is hard, I think.
I鈥檝e updated the above list as unist-diff is now a thing!
Nice! These look like super useful utilities (even beyond this use case).
Still unsure how to do this. I never really got the utilities to work. Transforming stuff with retext and then merging the changes back into remark is, well, hard.
Something for a far future, maybe!
Most helpful comment
Thought about this a short while, we probably need:
unist-diff](https://github.com/syntax-tree/unist-diff) (Array.<Patch> = diff(Node, Node))unist-patch(patch(Node, Array.<Patch>))mdast-util-patch-from-nlcst(Array.<Patch> = patchFromNLCST(Node, Array.<Patch>))the diff and patch would be ok, but changing nlcst patches to mdast patches is hard, I think.