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 &#8220Wink 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.

Trackbacks/Pingbacks

  1. Blogging Pro - Blog News, Tools and Hacks » Disable WP’s wpTexturize Inline2004.06.12
    www.bloggingpro.com/archives/2004/06/11/disable-wps-wptexturize-inline
  2. Blogging Pro - Blog News, Tools and Hacks2004.06.12
    www.bloggingpro.com/archives/2004/06/11/disable-wps-wptexturize-inline
  3. mathibus.com2004.06.26
    mathibus.com/archives/2004/06/25/texturize

7 Comments

  1. MaThIbUs says:

    That’s a great “hack” Smile

    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. dead_poet says:

    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. MaThIbUs says:

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

  4. markku says:

    No problem, mate! Smile

  5. MaThIbUs says:

    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 Rolls Eyes I promise I won’t mess around with my WP settings anymore Wink

  6. markku says:

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

    *Fixed now.*

  7. MaThIbUs says:

    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 Smile

Leave a Comment

Comments will be sent to the moderation queue.

Blo.gs Blogroll for WP-1.2 iPAP/SPAM