Item12278: TML WikiWord links need better handling by TMCE to avoid inconsistent links.
Priority: Enhancement
Current State: Closed
Released In: 1.1.7
Target Release: patch
Applies To: Extension
Component: WysiwygPlugin
Branches: Release01x01 trunk
Several recent tasks improved Link handling in Wysiwyg editing, by recognizing those links as real HTML links. This has caused some unanticipated behavior.
Topic contains an in-line wikiword
SomeWikiWord, when edited it is rendered as
<a href="SomeWikiWord">SomeWikiWord</a>
which displays like any other html link. If the user changes the link texst "AnotherWikiWord", the editor saves
<a href="SomeWikiWord">AnotherWikiWord</a>
, which is ultimately saved as
[[SomeWikiWord][AnotherWikiWord]]
Proposed solution is to stash the original wikiword in as a class in the link.
<a class="TMLwikiwordSomeWikiWord" href="SomeWikiWord">AnotherWikiWord</a>
During save,
HTML2TML/Node.pm
recovers the original wikiword. If the link text is still a WikiWord, and the href matches the original
WikiWord, then copy the
LinkText into the Href.
--
GeorgeClark - 30 Nov 2012
This fix seems to work.
diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
index c0f93f0..34a2272 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
@@ -1431,6 +1431,13 @@ sub _handleA {
( $this->{attrs}->{class}
&& $this->{attrs}->{class} =~ m/\bTMLlink\b/ );
+ my $origWikiword;
+ if ( $this->{attrs}->{class}
+ && $this->{attrs}->{class} =~ m/\bTMLwikiword(.*)\s?/ )
+ {
+ $origWikiword = $1;
+ }
+
# SMELL: Item11814 - decoding corrupts URL's that must be encoded, ex. embedded Newline
# No unit test covers why the decode is required. However restricting it to known
# protocols fixes Item11814. Need to figure out if this can just be removed?
@@ -1452,6 +1459,14 @@ sub _handleA {
$cleantext =~ s/<nop>//g;
$cleantext =~ s/^$this->{context}->{web}\.//;
+ if ( $origWikiword
+ && $href eq $origWikiword
+ && $cleantext =~ m/^(\w+\.)?($reww)$/ )
+ {
+ $topic = $2;
+ $href = $text;
+ }
+
# if the clean text is the known topic we can ignore it
if ( ( $cleantext eq $href || $href =~ /\.$cleantext$/ )
&& !$forceTML )
diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
index bcb2ca4..511a3f3 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
@@ -902,7 +902,7 @@ s/((^|(?<=[-*\s(]))$Foswiki::regex{linkProtocolPattern}:[^\s<>"]+[^\s*.,!?;:)<])
# Need to also include protected content marker as part of start wikiword delim
my $startww = qr/$WC::STARTWW|(?<=$TT2)/;
$text =~
-s/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOutSquab($1,$1)/geom;
+s/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOutSquab($1,$1,'TMLwikiword'.$1)/geom;
Foswiki::putBackBlocks( \$text, $removed, 'noautolink' );
}
--
GeorgeClark - 30 Nov 2012
This is checked into the trunk wysiwyg editor. I'd like to pull this into 1.1.7, as the current behavior is quite confusing.
--
GeorgeClark - 18 Dec 2012