Plugin Directory

Preserve Code Formatting

Author: coffee2code

Preserve formatting of code for display by preventing its modification by WordPress and other plugins while retaining original whitespace and characters.

NOTE: Use of the visual text editor will pose problems as it can mangle your intent in terms of ``` tags. I do not offer any support for those who have the visual editor active.

Notes:

Basically, you can just paste code into <code>, <pre>, and/or other tags you additionally specify and this plugin will:

  • Prevent WordPress from HTML-encoding 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)
  • Prevent most other plugins from modifying preserved code
  • Optionally preserve whitespace (in a variety of methods)
  • Optionally preserve code added in comments

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 <coded_br />).
  • By default this plugin filters 'the_content' (post content), 'the_excerpt' (post excerpt), and 'get_comment_text (comment content)'.

Example: A post containing this within ```: $wpdb->query(" INSERT INTO $tablepostmeta (post_id,meta_key,meta_value) VALUES ('$post_id','link','$extended') ");

Would, with this plugin enabled, look in a browser pretty much how it does above, instead of like: $wpdb->query(— INSERT INTO $tablepostmeta (post_id,meta_key,meta_value) VALUES ('$post_id','link','$extended') ―);

Download

FYI

Compatibility

+
=
Not enough data

2 people say it works.
1 person says it's broken.

Log in to vote.

67,3,2

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(2 ratings)