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

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
(cherry picked from commit f4d16e63cb349037bec2ecf4cbb1cd04f25c1eff)
---
M VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
1 file changed, 7 insertions(+), 3 deletions(-)


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

diff --git a/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js 
b/VisualEditor/resources/tiny_mce_plugins/bswikicode/plugin.js
index 2124cb6..5274a6b 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,7 +553,6 @@
 
                links = _links;
 
-
                if (links) {
                        for (var i = 0; i < links.length; i++) {
                                link = links[i].substr(2, links[i].length - 4);
@@ -566,11 +567,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,6 +597,8 @@
                                }
 
                                link = link.replace( "@@PIPE@@", "|" );
+                               link = link.replace( /@@LSQB@@/g, "[" );
+                               link = link.replace( /@@RSQB@@/g, "]" );
                                text = text.replace("[[" + link + "]]", 
linkHtml);
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/388395
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: REL1_27
Gerrit-Owner: Mglaser <gla...@hallowelt.biz>
Gerrit-Reviewer: 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