WordPress.org

Ready to get started?Download WordPress

Forums

Code and Preformatted text mess up :-( (8 posts)

  1. Rahul
    Member
    Posted 1 year ago #

    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.]

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

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

  3. Rahul
    Member
    Posted 1 year ago #

    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 :D

  4. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

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

  5. Rahul
    Member
    Posted 1 year ago #

    Any solution for that Sir?

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

  6. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Sorry - there isn't a fix for this. It's a by-product of the TinyMCE Visual Editor :-(

  7. Rahul
    Member
    Posted 1 year ago #

    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.. :-(

  8. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic