Changeset 590703
- Timestamp:
- 08/27/2012 12:39:16 AM (14 years ago)
- Location:
- preserved-html-editor-markup/trunk
- Files:
-
- 3 edited
-
admin.js (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
sb_preserved_markup.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
preserved-html-editor-markup/trunk/admin.js
r586992 r590703 203 203 return false; 204 204 }; 205 206 function fix_intra_tag_content(needle, haystack, placeholder, correct) { 207 //This will encode intra tag & intra quote content to prevent TinyMCE escaping 208 var repeat = true; 209 210 //look for needle (improperly encoded strings) in haystack (content inside valid html tags) 211 var regescape = new RegExp("(<[^>]*)(" + needle + ")([^>]*>)", "g"); 212 while (repeat) { 213 //replace with a placeholder value because replacing with the correct value would prevent downstream replacements 214 newstack = haystack.replace(regescape, "$1" + placeholder + "$3"); 215 //repeat process until transformations stop 216 if (newstack == haystack) repeat = false; 217 haystack = newstack; 218 } 219 220 //finally replace placeholder values with correct value (proper, unencoded strings); 221 if (correct) { 222 var regfix = new RegExp(placeholder, "g"); 223 return haystack.replace(regfix, correct); 224 } 225 else { 226 //<, > will need to be replaced after all other replacements 227 return haystack; 228 } 229 } 205 230 206 231 //on dom load … … 227 252 //Now we replace all those temporary html comments with spaces and newlines 228 253 o.data = o.unfiltered.replace(/<\!--mep-nl-->/g, "\r\n").replace(/<\!--mep-tab-->/g, " "); 254 255 //Fix broken >, <, &, etc symbols when they exist inside quote marks inside tag elements 256 o.data = fix_intra_tag_content("&", o.data, "{-mep-amp}", "&"); 257 o.data = fix_intra_tag_content(">", o.data, "{-mep-gts}"); 258 o.data = fix_intra_tag_content("<", o.data, "{-mep-lts}"); 259 o.data = fix_intra_tag_content("”", o.data, "{-mep-dbl-quote}", '"'); 260 o.data = fix_intra_tag_content("″", o.data, "{-mep-dbl-quote}", '"'); 261 o.data = o.data.replace(/{-mep-gts}/g, '>'); 262 o.data = o.data.replace(/{-mep-lts}/g, '<'); 229 263 230 264 //And finally remove the code tag hack from the markup … … 281 315 //finally: restore the whitespace back in pre & code tags 282 316 o.data = o.data.replace(/<mep-preserve-nl>/g, "\n").replace(/<mep-preserve-tab>/g, "\t").replace(/<mep-preserve-space>/g, " "); 317 318 //BUGFIX: add space between quotes and closing tags 319 o.data = o.data.replace(/"\/>/g, '" />'); 283 320 }); 284 321 }); -
preserved-html-editor-markup/trunk/readme.txt
r586992 r590703 15 15 It also supports HTML5 Block Anchor tags, something that is currently not supported in WP even via any existing plugins. 16 16 17 With version 1.2, you now have a little more control over how content is created. And most of the previous caveats to using this plugin are now resolved. 17 With version 1.3 you can now use inline CSS and JavaScript in the HTML editor and everything should be preserved. To be clear, this applies to tags only, like `onclick` events and style definitions - not script blocks themselves. To enable this feature you must disable the `wptexturize` and `convert_chars` filters by adding the following code to your theme's `functions.php`: 18 19 remove_filter("the_content", "wptexturize"); 20 remove_filter("the_content", "convert_chars"); 21 22 This new feature is pretty experimental at the moment. I tried to make it compatible with wptexturize but that proved close to impossible without duplicating a lot of core code in my plugin. It's also not compatible with TinyMCE Advanced when the "stop removing p and br tags" setting is enabled. 23 I've tested it on a variety of code samples and I'm pleased with the results but if you find any content that isn't preserved just open a support ticket and I should be able to fix it. 24 25 Since version 1.2, you now have a little more control over how content is created. And most of the previous caveats to using this plugin are now resolved. 18 26 19 27 1. You can now choose whether to use BR tags OR P tags for newlines. Even better you can use both, where one return key press injects a BR tag, and two return key presses will wrap a Paragraph tag. This is great for being able to wrap headers at specific break points all while enjoying the semantic perks of paragraphs. … … 54 62 This is a tough one. Not only do I have no idea why they're being trumped, but I also have a daughter that will be born pretty soon :D, and a project at work that is about to get hectic :( I'll try to fix it when I can but if you have the skills to help debug the help would be greatly appreciated. 55 63 64 = Does this plugin actually disable wpautop? = 65 66 Yes. And unlike virtually every other "disable wpautop" plugin this one will actually disable the client-side version of wpautop that runs when you switch between the Visual and HTML tabs. Even when using the P Tag mode or hybrid mode, wpautop is disabled and custom code is being used to inject paragraphs a little more intelligently. 67 56 68 = What exactly do the "Fix Posts" or "Fix XXX" buttons do to my content? = 57 69 … … 73 85 74 86 == Changelog == 75 87 = 1.3 = 88 * Added support for inline JavaScript and CSS, as long as the wptexturize and convert_chars filters are disabled. (Thanks to ViennaMex for pointed out the problem.) 89 * Added cache-buster for this plugin's JavaScript includes to prevent upgrade issues seen in version 1.2 (Thanks to dreamdancerdesign, peterdub & abbyj for troubleshooting support.) 90 * Special thanks to dreamdancerdesign for providing a live testing server - above and beyond. 76 91 = 1.2 = 77 92 * Added support for user-specified newline behavior per post type -
preserved-html-editor-markup/trunk/sb_preserved_markup.php
r586992 r590703 8 8 Author: Marcus E. Pope, marcuspope 9 9 Author URI: http://www.marcuspope.com 10 Version: 1. 210 Version: 1.3 11 11 12 12 Copyright 2011 Marcus E. Pope (email : me@marcuspope.com) … … 56 56 //replace all closing html tags with temp placeholders so texturize doesn't turn them into endash's 57 57 $s = preg_replace("/-->/m", "-mep-temp-closing-comment-tag->", $s); 58 58 59 59 //now let wptexturize do its work 60 //NOTICE: this function is highly volatile - it will alter intra-tag strings which is a terrible approach 60 61 $s = wptexturize($s); 61 62 … … 189 190 190 191 //finish up with functions that WP normally calls on the_editor_content 191 $c = convert_chars($c); 192 if (has_filter('the_content', 'convert_chars')) { 193 $c = convert_chars($c); 194 } 192 195 $c = htmlspecialchars($c, ENT_NOQUOTES); 193 196 $c = apply_filters('richedit_pre', $c); … … 298 301 299 302 /* fix WP html editor on client side */ 300 //TODO: thisdoes not work with symlinks (https://bugs.php.net/bug.php?id=46260).303 //TODO: __FILE__ does not work with symlinks (https://bugs.php.net/bug.php?id=46260). 301 304 // Create a filter for overriding so I don't have to copy this plugin from 302 // the svn repo to my own hg/git repos 303 wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))."admin.js"); 305 // the svn repo to my own hg/git repos 306 $plugin_data = get_plugin_data(__FILE__); 307 $cachebuster = $plugin_data['Version']; 308 309 wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))."admin.js?v=".$cachebuster); 304 310 //wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/sb_preserved_markup/admin.js'); 305 311
Note: See TracChangeset
for help on using the changeset viewer.