3

Is there a way to get the rich text field to automatically convert straight quotes to curly (smart) quotes? I'm not seeing anything on the redactorjs site or in the docs.

  • Do you want to convert it on input (on-save or while typing) or output? – Victor In Jun 20 '14 at 18:42
6

It turns out Smartdown should do the trick. It's a Craft plugin that adds MarkdownExtra and SmartyPants (the latter of which matters here) support to Twig.

SmartyPants is a rather ancient blogging plug-in from John Gruber for intelligently handling smart punctuation. Michel Fortin ran with it in the form of PHP SmartyPants, and most recently this Craft plugin by Experience.

Note: my first answer linked to a SmartyPants Craft filter by Experience that's apparently not finished. That one won't get you very far. :)

  • Well, there you go. Nice find. – Brad Bell Jun 20 '14 at 22:48
  • @BradBell Thanks. I sensed it was out there somewhere. – Matt Stein Jun 20 '14 at 22:49
2

There's also another great plugin I came across recently called Typogrify.

It also supports SmartyPants (as mentioned in another answer) along with several other nice typography improvements:

  • Uses SmartyPants library to convert:
    • Both single and double quotes to their curly versions.
    • Dashes (-- and ---) into en- and em-dash entities
    • Three consecutive dots (...) into an ellipsis entity
  • Prevents "widows" (having only a single word on the last line of a paragraph) by replacing the space between the last two words in a string with  .
  • Wraps ampersands with <span class="amp"> so they can be styled with CSS.
  • Wraps multiple capital letters in <span class="caps"> so they can be styled with CSS.
  • Puts a &thinsp; before and after an &ndash or &mdash;.
  • Wraps initial quotes in class="dquo" for double quotes or class="quo" for single quotes.

It does all this during template rendering via filters, not during save, if that matters to you.

https://github.com/jamiepittock/craft-typogrify

  • Agreed -- I just started using Typogrify as well. Solid. – Shanan Galligan Jun 19 '17 at 3:04
1

Not natively.

Your options would be to either write a redactor plugin that converts them on the fly or a Craft plugin that either converts them to curly quotes on save before saving them in the database or leaves them as straight in the database and converts them to curly quotes on display.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.