Disable WP’s wptexturize inline

One of WordPress’s unique features is the ability to apply block formatting and punctuation styling through the buit–in wpautop() and wptexturize() functions, respectively. However, this behavior fails on some markup combinations. The simple–looking "<strong>text wrapped with strong emphasis tag, with quotes outside</strong>" replaces the two instances of double–quotes with opening–double–quotes ( — escaped in HTML as &#8220;) instead of the typographically correct “ … ”. A simple workaround is to type the character entity itself, a simple task for those fairly familiar with semantic markup and typography.

On some occasions, you may want to disable the pretty formatting (wptexturize()) for an entire post; this is where Alex’s wp–unformatted (Link to his WP 1.2 plugins) comes handy. But what if you want to disable wptexturize() formatting for a sentence (or phrase, or snippet of text), inline?

A simple workaround: Use semantics! Most probably, it is a snippet of code you want untouched; then just wrap it with the <code> tag. You can also use <pre>, <kbd>, <style>, and <script>. But what if no tag fits the purpose? Wrap it with these comments (really, a hack!) instead: <!-- <pre> -->raw text, unformatted<!-- </pre> -->, where “raw text, unformatted” is the string of text you want untouched. Valid markup comments, simple hack, and it works.

Update: I’ve tested the hack I proposed and it seems to randomly mangle text, depending on the combination of words, characters, and punctuations. I guess the best option is to find solutions within the wptexturize() function. Better yet, just type the character entities.
Post your solutions if you find a different approach.

7 Responses

  1. Pingback: Blogging Pro - Blog News, Tools and Hacks » Disable WP’s wpTexturize Inline

  2. That’s a great “hack” :)

    However, the wptexturize() function seems to fail on some other occasions as well. You want an example? Well, I’ll quote some text from one of your previous posts:

    This medium of communication has witnessed real stories, messages of “I luv u”, “Hapi bday!”, even “Ur fired.”

    (Notice the quotes around the first two messages.)

    I think a fix would be adding some code to the function, which changes all double quotes that were left untouched after going through the normal function into &#8221; chars…

    But what if doing this kills all these hacks and plugins?

  3. i certainly do not understand the entry. ala kong alam dito eh.

    but the unrelated photos…yung places (though alam ko nde na bago sasabihin ko)…the way they were captured is just breathtaking.

    “Muli bang bubulagin ng isang nanunukso?
    Ang tinig mo sa hangin ay kalibre ng gabo”

  4. Pingback: Blogging Pro - Blog News, Tools and Hacks

  5. Pingback: mathibus.com

  6. I love relative linking, not absolute… e.g. if I want to link to your archives from your site, I’ll use <a href="/archives/">archives</a> instead of <a href="http://rebelpixel.com/archives/">archives</a>.

    So, on /wp-admin/options-general.php, I made my Blog address (URI) say /. Everything WP kept on working fine, instead of the trackbacks… D’OH!

    Thanks for fixing the link :)

Leave a Reply