Remark: Suggestions on integrating smartypants?

Created on 12 Jan 2017  路  6Comments  路  Source: remarkjs/remark

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?

馃憖 areexternal 馃檵 typquestion

Most helpful comment

Thought about this a short while, we probably need:

  • [x] [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.

All 6 comments

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:

  • [x] [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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gengjiawen picture gengjiawen  路  4Comments

niftylettuce picture niftylettuce  路  4Comments

CxRes picture CxRes  路  4Comments

rauschma picture rauschma  路  4Comments

KyleAMathews picture KyleAMathews  路  6Comments