Skip to content

Commit

Permalink
Item10089: Tidy them all
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@14689 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed May 5, 2012
1 parent f96115f commit d2d6d15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
13 changes: 9 additions & 4 deletions WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,9 @@ sub _handleA {
# there's text and an href
my $href = $this->{attrs}->{href};

my $forceTML = ( $this->{attrs}->{class} && $this->{attrs}->{class} =~ m/\bTMLlink\b/ );
my $forceTML =
( $this->{attrs}->{class}
&& $this->{attrs}->{class} =~ m/\bTMLlink\b/ );

# decode URL params in the href
$href =~ s/%([0-9A-F]{2})/chr(hex($1))/gei;
Expand All @@ -1445,7 +1447,8 @@ sub _handleA {

# if the clean text is the known topic we can ignore it
if ( ( $cleantext eq $href || $href =~ /\.$cleantext$/ )
&& !$forceTML ) {
&& !$forceTML )
{
return ( 0,
$WC::CHECK1
. $nop
Expand All @@ -1455,8 +1458,10 @@ sub _handleA {
. $WC::CHECK2 );
}
}
if ( $href =~ /${WC::PROTOCOL}[^?]*$/ && $text eq $href
&& !$forceTML ) {
if ( $href =~ /${WC::PROTOCOL}[^?]*$/
&& $text eq $href
&& !$forceTML )
{
return ( 0, $WC::CHECK1 . $nop . $text . $WC::CHECK2 );
}
if ( $text eq $href ) {
Expand Down
27 changes: 15 additions & 12 deletions WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,10 @@ s/<([A-Za-z]+[^>]*?)((?:\s+\/)?)>/"<" . $this->_appendClassToTag($1, 'TMLhtml')
$text =~
s/(\<a(\s+(href|target|title|class)=("(?:[^"\\]++|\\.)*+"|'(?:[^'\\]++|\\.)*+'|\S+))+\s*\>.*?\<\/a\s*\>)/$this->_liftOutGeneral($1, { tag => 'NONE', protect => 0, tmltag => 0 } )/gei;


# SMELL: Links inside protected tags like %SEARCH should not be treated as links...
# BUT %TAGS inside links must not be protected. Treat them as literal text.
$text =~ s/\[\[([^]]*)\]\[([^]]*)\]\]/$this->_protectMacrosInSquab($1,$2)/ge;
# SMELL: Links inside protected tags like %SEARCH should not be treated as links...
# BUT %TAGS inside links must not be protected. Treat them as literal text.
$text =~
s/\[\[([^]]*)\]\[([^]]*)\]\]/$this->_protectMacrosInSquab($1,$2)/ge;
$text =~ s/\[\[([^\]]*)\]\]/$this->_protectMacrosInSquab($1)/ge;

# Convert Foswiki tags to spans outside protected text
Expand Down Expand Up @@ -834,26 +834,29 @@ s/$WC::STARTWW(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}(
}

sub _liftOutSquab {
my $this = shift;
my $url = shift;
my $text = shift;
my $this = shift;
my $url = shift;
my $text = shift;
my $class = shift || '';

# Treat as old style link if embedded spaces in the url
return $this->_liftOut('[['.$url.']]', 'LINK') if ( $class eq 'TMLlink' && $url =~ m/\s/ );
return $this->_liftOut( '[[' . $url . ']]', 'LINK' )
if ( $class eq 'TMLlink' && $url =~ m/\s/ );

# Handle colour tags specially (hack, hack, hackity-HACK!
my $colourMatch = join( '|', grep( /^[A-Z]/, @WC::TML_COLOURS ) );
$text =~ s#%($colourMatch)%(.*?)%ENDCOLOR%#
_getNamedColour($1, $2)#oge;
_handleMarkup($text);

if ( $class ) {
if ($class) {
$class = " class='$class'";
}

return $this->_liftOutGeneral( "<a$class href=\"$url\">$text<\/a>",
{ tag => 'NONE', protect => 0, tmltag => 0 } );
return $this->_liftOutGeneral(
"<a$class href=\"$url\">$text<\/a>",
{ tag => 'NONE', protect => 0, tmltag => 0 }
);

}

Expand All @@ -864,7 +867,7 @@ sub _protectMacrosInSquab {

$url =~ s/%/$TT3/g;

if ( $text ) {
if ($text) {
return "[[$url][$text]]";
}
else {
Expand Down

0 comments on commit d2d6d15

Please sign in to comment.