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.

10 replies to “Disable WP’s wptexturize inline

  1. 1 MaThIbUs 1AM of June 3, 2004 [q]

    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?

  2. 2 dead_poet 9AM of June 6, 2004 [q]

    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”

  3. 3 Pingback from Blogging Pro - Blog News, Tools and Hacks » Disable WP’s wpTexturize Inline 1AM of June 12, 2004 Excerpt ↓

  4. 4 Trackback from Blogging Pro - Blog News, Tools and Hacks 9AM of June 12, 2004 Excerpt ↓

  5. 5 Trackback from mathibus.com 12AM of June 26, 2004 Excerpt ↓

  6. 6 MaThIbUs 12AM of June 26, 2004 [q]

    Sorry about those trackbacks, please remove them (except for the last one of course ;)) as they make me feel dumb.

  7. 7 markku 3AM of June 26, 2004 [q]

    No problem, mate! :)

  8. 8 MaThIbUs 4PM of June 26, 2004 [q]

    The link in this comment should point to http://mathibus.com/archives/2004/06/25/texturize/ instead of http://archives/2004/06/25/texturize/ — please fix that for me :roll: I promise I won’t mess around with my WP settings anymore ;)

  9. 9 markku 1PM of June 27, 2004 [q]

    Ohh, I didn’t notice that! What have you done with your code??? :)

    *Fixed now.*

  10. 10 MaThIbUs 5PM of June 27, 2004 [q]

    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 :)

Note: This website was designed to appear considerably well on a standards–compatible browser. If you see this message, your browser probably has poor support for CSS and XHTML. A browser upgrade is strongly recommended, it doesn’t cost anything at all. This site strongly recommends Mozilla Firefox. Visit the WebStandards.Org Browser Upgrade Campaign for more information.