Yes, i have found other questions to this topic, but no have the same topic exactly and no solution for my problem.
If you include code inside the html-tab and you switch to the visual mode, then format WP the code to a block, remove all breaks and leave lines, see the screenshots. I think this easier to understand as my bad english.
my example in html-tab
the same example after switch to visual
My tests for an solution.
i have test this to stop WP for this with the follow test plugin, also readable in this Gist 1663554
add_filter( 'tiny_mce_before_init', 'fb_tinymce', 9 );
function fb_tinymce( $init ) {
$init['fix_list_elements'] = FALSE;
$init['wpautop'] = FALSE;
$init['remove_linebreaks'] = FALSE;
$init['apply_source_formatting'] = TRUE;
$init['extended_valid_elements'] .= ',pre[*],code[*]';
return $init;
}
Maybe an other reader has an solution for this topic.
There is my solution – tehere is my solution of this problem:
Preserving tabs and line breaks in <pre><code> when switching from HTML to Visual Editor
Yep, it’s a total pain. 99% of the ‘disable wpautop’ tutorials completely miss the tab switch event. Anyway, you should try my plugin – http://wordpress.org/extend/plugins/preserved-html-editor-markup/
Not only will it protect your markup from being mangled by wpautop, but it will preserve line breaks and indentation while still allowing you to use both the HTML editor and the Visual editor.
The current version will really disable wpautop, so if you have existing content that depends on wpautop your site may not render properly without modifying the existing content. I’m working on a new version that will batch reformat existing content to correct this. It should be ready by the end of the week.
I think the easiest solution for what you’re describing is a plugin like: http://wordpress.org/extend/plugins/wp-no-format/
However, you might also want to look at syntax highlighting plugins… there is even one for embedding gists by id.
Use Scripts n Styles plugin. http://wordpress.org/extend/plugins/scripts-n-styles/ It was invented to “Jump through hoops” and avoid wpautop bugs, specifically the tab-switching bugs.
You’d enter [sns_shortcode name=”{name}”] in the editor, and your content in the Shortcodes tab. It’s syntax highlighted and I’ve worked hard to code it well.