WordPress.org

Ready to get started?Download WordPress

Forums

Plugin: Preserve Code Formatting (4 posts)

  1. Plugin: Preserve Code Formatting

    Description:
    Preserve formatting for text within <code> and <pre> tags (other tags can be defined as well). Helps to preserve code indentation, multiple spaces, prevents WP's fancification of text (ie. ensures quotes don't become curly, etc).

    Details can be found at the plugin's homepage:
    http://www.coffee2code.com/archives/2005/03/29/plugin-preserve-code-formatting/

    All of my plugins can be found at:
    http://www.coffee2code.com/wp-plugins/

    Notes:

    Bascially, you can just paste code into <code>, <pre>, and/or other tags you additionally specify and this plugin will:
    * prevent all "wptexturization" of text (i.e. single- and double-quotes will not become curly; "--" and "---" will not become en dash and em dash,
    respectively; "..." will not become a horizontal ellipsis, etc)
    * optionally preserve multiple spaces (including indentations) (for the most part, that is; it changes 2+ consecutive "\n" to "\n\n" and "\t" to 3 spaces)

    Keep these things in mind:
    * ALL embedded HTML tags and HTML entities will be rendered as text to browsers, appearing exactly as you wrote them (including any ).
    * By default this plugin filters both 'the_content' (post contents), 'the_excerpt' (post excerpts), and 'get_comment_text'.

    It's what I have been using to formatting all the code I present on my site.

  2. ColdForged
    Member
    Posted 9 years ago #

    Hawt. Must try this.

  3. jamesfiv
    Member
    Posted 8 years ago #

    It did work somewhat for me. But it has problems with the ampersand. When I go into the html source editor to edit a post or page, I notice that the code is changed there, and then in the final result too. Ampersand is generated as ampersandamp; thus messing up the code. Whoever will look at it will not just be able to copy and paste, and having to explain why certainly doesn't whet the appetite for the code.

    I was trying to demonstrate a piece of code that I had made as a shortcut for writing google custom RSS feeds. Everything else is there, only the search parameter must be typed in. Unfortunately google includes an ampersand in the code. Everytime I go into the html source editor I have to change ampersandamp;amp;amp;amp; back to the ampersand. And that for every page I have RSS on, even just the sample code I wanted to include.

    Any ideas?

  4. craibuc
    Member
    Posted 7 years ago #

    i can't seem to get this plugin (v0.9) to activate in WP 2. do you have any suggestions?

Topic Closed

This topic has been closed to new replies.

About this Topic