New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions on integrating smartypants? #224

Closed
KyleAMathews opened this Issue Jan 12, 2017 · 6 comments

Comments

2 participants
@KyleAMathews

KyleAMathews commented Jan 12, 2017

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?

@KyleAMathews

This comment has been minimized.

KyleAMathews commented Jan 12, 2017

Also it's not crazy performant as it's running retext a gazillion times.

@wooorm

This comment has been minimized.

Member

wooorm commented Jan 12, 2017

I unfortunately have no idea how to properly do that, with retext, currently.

It’s 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’m 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’s probably ways to deal with that. Prosemirror deals with similar problems, and things like React or virtual-dom of course. But I’m not entirely sure where to start.

😬

@wooorm

This comment has been minimized.

Member

wooorm commented Jan 13, 2017

Thought about this a short while, we probably need:

  • 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.

@wooorm

This comment has been minimized.

Member

wooorm commented Jan 15, 2017

I’ve updated the above list as unist-diff is now a thing!

@KyleAMathews

This comment has been minimized.

KyleAMathews commented Jan 23, 2017

Nice! These look like super useful utilities (even beyond this use case).

@wooorm

This comment has been minimized.

Member

wooorm commented Oct 21, 2018

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!

@wooorm wooorm closed this Oct 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment