Title: Code and Preformatted text mess up :-(
Last modified: August 20, 2016

---

# Code and Preformatted text mess up :-(

 *  [Rahul](https://wordpress.org/support/users/rahulrulez/)
 * (@rahulrulez)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/)
 * Hello,
 * I run my developer blog at [http://www.wrapcode.com](http://www.wrapcode.com)
 * Since I write articles about programming and web development. I really need to
   write codes in my article.. When I write a code in `< code >` or `< pre >` tag
   it works fine for first Save Draft or Publish.. Whenever the edit post is refreshed
   it replace all <, >, & with <, > and all other HTML codes.. Formatting just mess
   up.
 * I tried using every Syntax Highlighter plugin out there.. But whenever I save
   draft or update post, this happens. It take a lot of time to reformat all the
   code.
 * Any possible solution?
 * Regards,
    Rahul.
 * _[Moderator Note: Please post code or markup snippets between backticks or use
   the code button. As it stands, your code may now have been permanently damaged/
   corrupted by the forum’s parser.]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143889)
 * Which editor are you using? Are you switching editors at any point?
 *  Thread Starter [Rahul](https://wordpress.org/support/users/rahulrulez/)
 * (@rahulrulez)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143890)
 * Well I use default editor that comes with WordPress.. I only switch to **Visual**
   and **HTML** whenever I need.
 * Even if I don’t switch and Save Draft, code messes up 🙁
 * Thanks a lot for super quick reply 😀
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143893)
 * Never, ever, switch editing tabs on any given Post or Page. That will create 
   just the kind of issues that you describe.
 *  Thread Starter [Rahul](https://wordpress.org/support/users/rahulrulez/)
 * (@rahulrulez)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143894)
 * Any solution for that Sir?
 * Sometimes, code just mess up when I save draft and the page automatically refreshes:/
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143927)
 * Sorry – there isn’t a fix for this. It’s a by-product of the TinyMCE Visual Editor
   🙁
 *  Thread Starter [Rahul](https://wordpress.org/support/users/rahulrulez/)
 * (@rahulrulez)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143947)
 * Well,
 * I haven’t switched editor and written an article with code blocks in to it.
 * I saved a draft and clicked on preview. After couple of Saves.. Again it messed
   up.. This makes me sick and loosing my faith on WordPress 🙁
 * I am using SyntaxHighlighter Evolved plugin.
 * 🙁 Help me.
 * I am not switching editor while editing and still this is happening..
 * For an instance,
 *     ```
       class My_Widget extends WP_Widget {
   
       	public function __construct() {
       		// widget actual processes
       	}
   
        	public function form( $instance ) {
       		// outputs the options form on admin
       	}
   
       	public function update( $new_instance, $old_instance ) {
       		// processes widget options to be saved
       	}
   
       	public function widget( $args, $instance ) {
       		// outputs the content of the widget
       	}
   
       }
       register_widget( 'My_Widget' );
       ```
   
 * becomes
 * `<br />class My_Widget extends WP_Widget {<br /><br /><%%KEEPWHITESPACE%%> public
   function __construct() {<br /><%%KEEPWHITESPACE%%> // widget actual processes
   <br /><%%KEEPWHITESPACE%%> }<br /><br /><%%KEEPWHITESPACE%%> public function 
   form( $instance ) {<br /><%%KEEPWHITESPACE%%> // outputs the options form on 
   admin<br /><%%KEEPWHITESPACE%%> }<br /><br /><%%KEEPWHITESPACE%%> public function
   update( $new_instance, $old_instance ) {<br /><%%KEEPWHITESPACE%%> // processes
   widget options to be saved<br /><%%KEEPWHITESPACE%%> }<br /><br /><%%KEEPWHITESPACE%%
   > public function widget( $args, $instance ) {<br /><%%KEEPWHITESPACE%%> // outputs
   the content of the widget<br /><%%KEEPWHITESPACE%%> }<br /><br />}<br />register_widget('
   My_Widget' );<br /&gt`
 * After saving a draft and previewing.. 🙁
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143948)
 * What happens if you don’t use that plugin. I post code inside `<pre>` and `<code
   >` tags all of the time and I haven’t hit any problems.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Code and Preformatted text mess up :-(’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [formatting](https://wordpress.org/support/topic-tag/formatting/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/code-and-preformatted-text-mess-up/#post-3143948)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
