Item14253: WysiwygPlugin inserts extra spaces in front of square bracket links.

pencil
Priority: Normal
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Extension
Component: WysiwygPlugin
Branches: Release02x01 master
Reported By: MichaelDaum
Waiting For:
Last Change By: GeorgeClark
You edit:

"[[WebHome][This is a link]"

You get

" [[WebHome][This is a link]"

-- MichaelDaum - 13 Dec 2016

I added a unit test, but with all things HTML2TML, white space issues are a royal pain to fix. The code that handles generating squab link does not output an extra space, so it's something deeper in the conversion process.

-- GeorgeClark - 16 Dec 2016

Found a 2nd condition that also adds white space. "WebHome" - a link without link text. And I've found a fix. No other tests fail, but this is a minefield and I'm reluctant to check it in!

diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
index c316203..b5e3846 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
@@ -1534,7 +1534,7 @@ sub _handleA {
 
         #print STDERR "TEXT ($text) HREF ($href)\n";
         if ( $text eq $href ) {
-            return ( 0, $WC::CHECKw . '[' . $nop . '[' . $href . ']]' );
+            return ( 0, '[' . $nop . '[' . $href . ']]' );
         }
 
         # we must quote square brackets in [[...][...]] notation
@@ -1544,7 +1544,7 @@ sub _handleA {
         $href =~ s/[]]/%5D/g;
 
         return ( 0,
-            $WC::CHECKw . '[' . $nop . '[' . $href . '][' . $text . ']]' );
+            '[' . $nop . '[' . $href . '][' . $text . ']]' );
     }
     elsif ( $this->{attrs}->{name} ) {
 
diff --git a/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm b/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
index 61db4df..abf8ec0 100644
--- a/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
+++ b/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
@@ -1276,6 +1276,8 @@ EVERYWHERE
         name => 'Item14253LinkSpaces',
         tml  => <<"HERE",
 Text "[[WebHome][This is a link]]" Follows
+
+More "[[WebHome]]" Follows
 HERE
     },
     {

-- GeorgeClark - 16 Dec 2016

Note, going back using git log -L, the $WC:CHECKw has been in the code since the original import. I can't explain why it might be needed.

-- GeorgeClark - 16 Dec 2016
 
Topic revision: r5 - 18 Feb 2017, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy