Support » Fixing WordPress » Code and Preformatted text mess up :-(

  • Hello,

    I run my developer blog at 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

    (@esmi)

    Forum Moderator

    Which editor are you using? Are you switching editors at any point?

    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

    (@esmi)

    Forum Moderator

    Never, ever, switch editing tabs on any given Post or Page. That will create just the kind of issues that you describe.

    Any solution for that Sir?

    Sometimes, code just mess up when I save draft and the page automatically refreshes :/

    esmi

    (@esmi)

    Forum Moderator

    Sorry – there isn’t a fix for this. It’s a by-product of the TinyMCE Visual Editor 🙁

    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

    (@esmi)

    Forum Moderator

    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.