diff --git a/syntaxhighlighter.js b/syntaxhighlighter.js index 8a95a8d..e0ebd59 100644 --- a/syntaxhighlighter.js +++ b/syntaxhighlighter.js @@ -1,6 +1,6 @@ ( function($) { var shortcodes = window.syntaxHLcodes || 'sourcecode', - regex = new RegExp( '(?:
\\s*)?(\\[(' + shortcodes + ')[^\\]]*\\][\\s\\S]*?\\[\\/\\2\\])(?:\\s*<\\/pre>)?', 'gi' ); + regex = new RegExp( '(?:\\s*)?(\\[(' + shortcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]*?\\[\\/\\2\\])(?:\\s*<\\/pre>)?', 'gi' ); window.syntaxHLescape = {}; diff --git a/syntaxhighlighter_mce-4.js b/syntaxhighlighter_mce-4.js index cdefb2c..0c23c2e 100644 --- a/syntaxhighlighter_mce-4.js +++ b/syntaxhighlighter_mce-4.js @@ -5,7 +5,7 @@ tinymce.PluginManager.add( 'syntaxhighlighter', function( editor ) { editor.on( 'BeforeSetContent', function( event ) { var shortcodes = window.syntaxHLcodes || 'sourcecode', - regex = new RegExp( '(?:\\s*)?(?:
\\s*)?(\\[(' + shortcodes + ')[^\\]]*\\][\\s\\S]*?\\[\\/\\2\\])(?:\\s*<\\/pre>)?(?:\\s*<\\/p>)?', 'gi' ); + regex = new RegExp( '(?:\\s*)?(?:
\\s*)?(\\[(' + shortcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]*?\\[\\/\\2\\])(?:\\s*<\\/pre>)?(?:\\s*<\\/p>)?', 'gi' ); if ( event.content && event.content.indexOf( '[' ) !== -1 ) { event.content = event.content.replace( regex, function( match, shortcode ) { diff --git a/syntaxhighlighter_mce.js b/syntaxhighlighter_mce.js index 6c360ba..1d8bc3f 100644 --- a/syntaxhighlighter_mce.js +++ b/syntaxhighlighter_mce.js @@ -39,7 +39,7 @@ if ( typeof syntaxHLcodes == 'undefined' ) { _visualToHtml : function(content) { content = tinymce.trim(content); // 2
get converted to \n\n and are needed to preserve the next- content = content.replace(new RegExp('(
\\s*)?(\\[(' + syntaxHLcodes + ')[^\\]]*\\][\\s\\S]*?\\[\\/\\3\\])(\\s*<\\/pre>)?', 'gi'), + content = content.replace(new RegExp('(\\s*)?(\\[(' + syntaxHLcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]*?\\[\\/\\3\\])(\\s*<\\/pre>)?', 'gi'), function(a) { a = a.replace( /
([\t ])/g, '
<%%KEEPWHITESPACE%%>$1' ); return a + '
'; @@ -51,14 +51,14 @@ if ( typeof syntaxHLcodes == 'undefined' ) { _htmlToVisual : function(content) { content = tinymce.trim(content); - content = content.replace(new RegExp('(\\s*)?(
\\s*)?(\\[(' + syntaxHLcodes + ')[^\\]]*\\][\\s\\S]*?\\[\\/\\4\\])(\\s*<\\/pre>)?(\\s*<\\/p>)?', 'gi'), '$3'); + content = content.replace(new RegExp('(\\s*)?(
\\s*)?(\\[(' + syntaxHLcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]*?\\[\\/\\4\\])(\\s*<\\/pre>)?(\\s*<\\/p>)?', 'gi'), '$3'); content = content.replace(/<\/pre>/gi, '\n'); // Remove anonymous, empty paragraphs. content = content.replace(/(\s| )*<\/p>/mg, ''); // Look for
in the [tag]s, replace with
- content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')[^\\]]*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), + content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), function(a) { return a.replace(/
[\r\n]*/g, '
').replace(/<\/?p( [^>]*)?>[\r\n]*/g, '
'); }); @@ -85,7 +85,7 @@ function pre_wpautop2(content) { content = this._pre_wpautop(content); - content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')[^\\]]*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), + content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), function(a) { return a.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&').replace(/<%%KEEPWHITESPACE%%>/g, ''); }); @@ -95,7 +95,7 @@ function pre_wpautop2(content) { function wpautop2(content) { // js htmlspecialchars - content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')[^\\]]*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), + content = content.replace(new RegExp('\\[(' + syntaxHLcodes + ')(?:\\s+[^\\]])*\\][\\s\\S]+?\\[\\/\\1\\]', 'gi'), function(a) { return a.replace(/&/g, '&').replace(//g, '>'); });