ItSpiderman has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391027 )

Change subject: [WIP] VisualEditor: Pre tag parsing
......................................................................

[WIP] VisualEditor: Pre tag parsing

Change-Id: I1bea5d976310f445735facf3d2160330bf57afb3
ERM: #1188
---
M VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/27/391027/1

diff --git a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js 
b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
index 8362b07..52b7127 100644
--- a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
+++ b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
@@ -1977,11 +1977,20 @@
        function _preservePres(text, skipnowiki) {
                var i;
 
+               var preMatcherRegex = 
/<pre[^>]*?(?!bs_pre_from_space)[^>]*?>([\S\s]*?)<\/pre>/;
                _preTags = false;
-               _preTags = 
text.match(/<pre[^>]*?(?!bs_pre_from_space)[^>]*?>([\S\s]*?)<\/pre>/gmi);
+               _preTags = text.match(preMatcherRegex + "gmi");
 
                if (_preTags) {
                        for (i = 0; i < _preTags.length; i++) {
+                               var preMatcher = new RegExp(preMatcherRegex, 
"gmi" );
+                               var matches = preMatcher.exec( _preTags[i] );
+                               var preContent = matches[1];
+
+                               preContent = preContent.replace( /</gmi, "&lt" 
);
+                               preContent = preContent.replace( />/gmi, "&gt" 
);
+                               _preTags[i] = _preTags[i].replace( matches[1], 
preContent );
+
                                text = text.replace(_preTags[i], "@@@PRE" + i + 
"@@@");
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/391027
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1bea5d976310f445735facf3d2160330bf57afb3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_27
Gerrit-Owner: ItSpiderman <d.savulje...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to