hasgeek / coaster

Common patterns for Flask apps
http://coaster.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
69 stars 13 forks source link

Typography plugin #94

Open jace opened 8 years ago

jace commented 8 years ago

The Zine typography plugin (@jace's branch) offers better accuracy than Smartypants. Since it parses HTML and not markdown, it can be applied on both markdown and richtext fields.

Consider this text: I'm positive I was 5'10" by the late '90s. Smartypants rendering: I’m positive I was 5’10” by the late ‘90s. Correct rendering: I’m positive I was 5′10″ by the late ’90s.

However, since the Zine plugin is written for Zine's since-abandoned HTML parser, it needs to be rewritten for html5lib. The Zine parser notably differs from html5lib in how it handles text outside a tag.

Caveat: This plugin, like Smartypants, is a batch parser and breaks the realtime WYSIWYG expectations of a richtext widget. Since richtext fields don't store original and rendered text separately, it is also destructive: parser errors cannot be recovered from.

jace commented 4 years ago

Bumping this up. Our Markdown parser now has its first HTML tree processor. This is now a matter of porting from Zine's HTML parser to ElementTree, and they seem to have similar APIs.