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

Change subject: VisualEditor: Fix for broken syntax by "link in caption"
......................................................................

VisualEditor: Fix for broken syntax by "link in caption"

If wiki text contains an image that has another link in its caption
and also the same link from the caption is used again on page, syntax
breaks.

Its because when parsing the second link, it finds it also in the image
caption and replaces it with html.

Since thumbs and framed images are not parsed with a frame anyway, caption
is not important in VE, so i used just escaping so that it doesnt break

Change-Id: I972cac06b3f29af6e216ae314dfafa4949821270
ERM: #7784
---
M VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
1 file changed, 10 insertions(+), 3 deletions(-)


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

diff --git a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js 
b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
index 2124cb6..c4001cc 100644
--- a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
+++ b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
@@ -474,6 +474,8 @@
                                        continue;
                                }
                                if ( property == 'caption' ) {
+                                       value = value.replace( /@@LSQB@@/g, "[" 
);
+                                       value = value.replace( /@@RSQB@@/g, "]" 
);
                                        imageCaption = value;
                                        continue;
                                }
@@ -551,13 +553,13 @@
 
                links = _links;
 
-
                if (links) {
                        for (var i = 0; i < links.length; i++) {
                                link = links[i].substr(2, links[i].length - 4);
                                linkParts = link.split("|");
                                linkTarget = linkParts[0];
                                linkLabel = linkParts[0];
+
 
                                // FS#134: Cleanup specials within Link
                                linkTarget = linkTarget.replace(/\<.*?\>/g, "");
@@ -566,11 +568,12 @@
                                        if ( (linkParts[1].trim() === "") ) {
                                                linkLabel = 
linkTarget.replace(/(.*:)?([^,\(]*)(.*)/, "$2");
                                        } else {
-                                               linkLabel = linkParts[1];
+                                               linkLabel = linkParts[ 
linkParts.length -1 ];
                                        }
                                }
 
-
+                               link = link.replace( /\[/g, "@@LSQB@@" );
+                               link = link.replace( /\]/g, "@@RSQB@@" );
                                linkHtml = anchorFormat.format(
                                        encodeURI( 'bs://' + linkTarget 
),//escape(linkTarget), // href
                                        linkLabel,                              
                                                                // 
<a>linkLabel</a>
@@ -595,8 +598,12 @@
                                }
 
                                link = link.replace( "@@PIPE@@", "|" );
+                               link = link.replace( /@@LSQB@@/g, "[" );
+                               link = link.replace( /@@RSQB@@/g, "]" );
                                text = text.replace("[[" + link + "]]", 
linkHtml);
+
                        }
+
                }
 
                //Also find protocol independent links

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I972cac06b3f29af6e216ae314dfafa4949821270
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to