Forums

Please give us the option to turn of smart "quotes" (14 posts)

  1. harishankar
    Member
    Posted 10 months ago #

    Smart quotes make pasted code useless. Most programming code uses just ordinary double quotes and single quotes. Using other characters renders posted code useless.

    I hope the WP developers give us a way to turn off smart quotes, because it's a serious problem when you paste code on your blog and expect users to have to manually convert the quotes to ordinary single and double quotes.

  2. Otto42
    Moderator
    Posted 10 months ago #

    Smart quotes are performed by the wptexturize function. You can disable them by determining what the filter is and disabling it in your theme.

    Example: Your post content is filtered through "the_content". So you want to turn off wptexturize for that filter. You do so by adding this to your theme's functions.php file:
    remove_filter('the_content', 'wptexturize');

    If you wanted to do it for comments instead, you'd do this:
    remove_filter('comment_text', 'wptexturize');

    And so on. The idea is to figure out exactly where you want to remove the filter from.

  3. harishankar
    Member
    Posted 10 months ago #

    I've created my own theme for my blog (from scratch) so I don't have a functions.php file for it.

    Should I create one. Or can that line be added to index.php or header.php?

  4. Otto42
    Moderator
    Posted 10 months ago #

    No, it must be in functions.php. So just create one. Make sure that it starts with <?php and ends with ?> and has NO blank lines or whitespace outside of those tags. The file must not produce any output.

  5. harishankar
    Member
    Posted 10 months ago #

    Thank you. I will try it out.

  6. gfindlay
    Member
    Posted 10 months ago #

    There's also the option of using one of the plugins that do this automatically for you...

    Try TextControl for one, which will let you change it globally, or Alex King has one that does it post by post with custom settings.

    All you need to do is do a google search, that's what I did.

  7. viciouslime
    Member
    Posted 10 months ago #

    Thank you so much for this thread!!!

  8. amandabee
    Member
    Posted 9 months ago #

    Thanks.

    I'm spamming this thread with keywords in case anyone else is looking for this by searching for help turning of extended characters or fancy quotes or curly quotes.

    Got that? extended characters or fancy quotes or curly quotes -- these terms are wrong! You should be searching for smart quotes.

  9. alexgenaud
    Member
    Posted 8 months ago #

    Thanks everyone. This post was very useful to me. In addition, I've found ampersand (&) conversion to the numeric character reference 038 very annoying. Disabling wptexturize does not do the trick.

    grep -r 038 wp-*

    Added lines to 'wp-includes/formatting.php' line 396 (WordPress 2.2.2) (ironically, the code below is likely to get messed up):

    // Converts lone & characters into & (a.k.a. &amp;)
    $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content);
    // unless it's lead by double hashes
    $content = str_replace('##&#038;', '&', $content);

    Now, whenever I need a real ampersand I precede it with two hashes (##&). I don't suppose that's "the right thing" to do. Any other suggestions?

  10. mlanger
    Member
    Posted 8 months ago #

    I'd just like WordPress to automatically turn off smart quotes for any text within <code></code> tags. Is there any way to hack WordPress to get that effect? I don't mind typing in the codes for other stuff (like < and >).

  11. StrangeAttractor
    Member
    Posted 7 months ago #

    There's a plugin called WP-untexturize. That did the trick for me.

    I agree that this should be something you can turn off without a plug-in, though -- it's annoying that smart quotes are the default. Smart quotes look bad with certain fonts, and also can mess up apostrophes.

    You can find the plugin here:
    http://www.coffee2code.com/archives/2004/06/27/plugin-wpuntexturize/

  12. planetmike
    Member
    Posted 4 months ago #

    I just released a plugin that disables smart quotes (currently only apostrophes and quotation marks) only within code blocks. I'd love to get your feedback on it. It can be downloaded from my site: http://www.planetmike.com

  13. ffosterdd
    Member
    Posted 2 weeks ago #

    I just released a plugin that disables smart quotes (currently only apostrophes and quotation marks) only within code blocks. I'd love to get your feedback on it. It can be downloaded from my site: http://www.planetmike.com

    It took me a while to find the quote, for others you may have more downloaders if you link directly to the page of this plugin.

  14. ffosterdd
    Member
    Posted 2 weeks ago #

    or I guess I could do it for you: (http://www.planetmike.com/plugins/codequote/)

Reply

You must log in to post.

About this Topic