Changeset 4294
- Timestamp:
- 06/24/09 19:53:49 (3 years ago)
- Location:
- trunk/WysiwygPlugin
- Files:
-
- 2 edited
-
lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm (modified) (3 diffs)
-
test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
r4292 r4294 601 601 602 602 my $xmltags = $this->{opts}->{xmltag}; 603 603 604 # Take out custom XML tags 604 605 sub _takeOutCustomXmlProcess { 605 606 my ( $this, $state, $scoop ) = @_; 606 607 my $params = $state->{tagParams}; 607 my $tag = $state->{tag};608 my $tag = $state->{tag}; 608 609 my $markup = "<$tag$params>$scoop</$tag>"; 609 if ( $this->{opts}->{xmltag}->{$tag}->($markup)) {610 if ( $this->{opts}->{xmltag}->{$tag}->($markup) ) { 610 611 return $this->_liftOut( $markup, 'PROTECTED' ); 611 612 } 612 613 else { 613 return $this->_liftOut( "<$tag$params>", 'PROTECTED' ) . $scoop . $this->_liftOut( "</$tag>", 'PROTECTED' ); 614 return $this->_liftOut( "<$tag$params>", 'PROTECTED' ) . $scoop 615 . $this->_liftOut( "</$tag>", 'PROTECTED' ); 614 616 } 615 617 } … … 624 626 625 627 sub _takeOutBlocks { 628 626 629 # my ( $this, $intext, $tag ) = @_; 627 630 … … 653 656 my $scoop; 654 657 655 # &$fn may rely on the existence of these fields, 658 # &$fn may rely on the existence of these fields, 656 659 # and may add more fields, if needed 657 660 my %state = ( tag => $tag, n => 0, tagParams => undef ); -
trunk/WysiwygPlugin/test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm
r4292 r4294 82 82 exec => $TML2HTML | $ROUNDTRIP, 83 83 name => 'UnspecifiedCustomXmlTag', 84 html => '<p>' . $protecton . '<customtag>' . $protectoff . 'some > text' . $protecton . '</customtag>' . $protectoff . '</p>', 85 tml => '<customtag>some > text</customtag>', 86 finaltml => '<customtag>some > text</customtag>', 84 html => '<p>' 85 . $protecton 86 . '<customtag>' 87 . $protectoff 88 . 'some > text' 89 . $protecton 90 . '</customtag>' 91 . $protectoff . '</p>', 92 tml => '<customtag>some > text</customtag>', 93 finaltml => '<customtag>some > text</customtag>', 87 94 }, 88 95 { 89 exec => $TML2HTML | $ROUNDTRIP, 90 name => 'DisabledCustomXmlTag', 91 setup => sub { Foswiki::Plugins::WysiwygPlugin::addXMLTag('customtag', sub { 0 } ); }, 92 html => '<p>' . $protecton . '<customtag>' . $protectoff . 'some > text' . $protecton . '</customtag>' . $protectoff . '</p>', 93 tml => '<customtag>some > text</customtag>', 94 finaltml => '<customtag>some > text</customtag>', 96 exec => $TML2HTML | $ROUNDTRIP, 97 name => 'DisabledCustomXmlTag', 98 setup => sub { 99 Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 100 sub { 0 } ); 101 }, 102 html => '<p>' 103 . $protecton 104 . '<customtag>' 105 . $protectoff 106 . 'some > text' 107 . $protecton 108 . '</customtag>' 109 . $protectoff . '</p>', 110 tml => '<customtag>some > text</customtag>', 111 finaltml => '<customtag>some > text</customtag>', 95 112 }, 96 113 { 97 exec => $TML2HTML | $ROUNDTRIP, 98 name => 'CustomXmlTag', 99 setup => sub { Foswiki::Plugins::WysiwygPlugin::addXMLTag('customtag', sub { 1 } ); }, 100 html => '<p>' . $protecton . '<customtag>some > text</customtag>' . $protectoff . '</p>', 101 tml => '<customtag>some > text</customtag>', 114 exec => $TML2HTML | $ROUNDTRIP, 115 name => 'CustomXmlTag', 116 setup => sub { 117 Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 118 sub { 1 } ); 119 }, 120 html => '<p>' 121 . $protecton 122 . '<customtag>some > text</customtag>' 123 . $protectoff . '</p>', 124 tml => '<customtag>some > text</customtag>', 102 125 }, 103 126 { 104 exec => $TML2HTML | $ROUNDTRIP, 105 name => 'CustomXmlTagWithAttributes', 106 setup => sub { Foswiki::Plugins::WysiwygPlugin::addXMLTag('customtag', sub { 1 } ); }, 107 html => '<p>' . $protecton . '<customtag with="attributes"><br /> formatting > preserved<br /></customtag>' . $protectoff . '</p>', 108 tml => <<BLAH, 127 exec => $TML2HTML | $ROUNDTRIP, 128 name => 'CustomXmlTagWithAttributes', 129 setup => sub { 130 Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 131 sub { 1 } ); 132 }, 133 html => '<p>' 134 . $protecton 135 . '<customtag with="attributes"><br /> formatting > preserved<br /></customtag>' 136 . $protectoff . '</p>', 137 tml => <<BLAH, 109 138 <customtag with="attributes"> 110 139 formatting > preserved … … 183 212 184 213 # Reset the extendable parts of WysiwygPlugin 185 %Foswiki::Plugins::WysiwygPlugin::xmltag = ();214 %Foswiki::Plugins::WysiwygPlugin::xmltag = (); 186 215 %Foswiki::Plugins::WysiwygPlugin::xmltagPlugin = (); 187 216 188 217 # Test-specific setup 189 if ( exists $args->{setup}) {218 if ( exists $args->{setup} ) { 190 219 $args->{setup}->(); 191 220 } … … 201 230 expandVarsInURL => 202 231 \&Foswiki::Plugins::WysiwygPlugin::expandVarsInURL, 203 xmltag => \%Foswiki::Plugins::WysiwygPlugin::xmltag,232 xmltag => \%Foswiki::Plugins::WysiwygPlugin::xmltag, 204 233 } 205 234 ); 206 235 207 236 # Test-specific cleanup 208 if ( exists $args->{cleanup}) {237 if ( exists $args->{cleanup} ) { 209 238 $args->{cleanup}->(); 210 239 } … … 223 252 224 253 # Reset the extendable parts of WysiwygPlugin 225 %Foswiki::Plugins::WysiwygPlugin::xmltag = ();254 %Foswiki::Plugins::WysiwygPlugin::xmltag = (); 226 255 %Foswiki::Plugins::WysiwygPlugin::xmltagPlugin = (); 227 256 228 257 # Test-specific setup 229 if ( exists $args->{setup}) {258 if ( exists $args->{setup} ) { 230 259 $args->{setup}->(); 231 260 } … … 241 270 expandVarsInURL => 242 271 \&Foswiki::Plugins::WysiwygPlugin::expandVarsInURL, 243 xmltag => \%Foswiki::Plugins::WysiwygPlugin::xmltag,272 xmltag => \%Foswiki::Plugins::WysiwygPlugin::xmltag, 244 273 } 245 274 ); … … 258 287 259 288 # Test-specific cleanup 260 if ( exists $args->{cleanup}) {289 if ( exists $args->{cleanup} ) { 261 290 $args->{cleanup}->(); 262 291 } … … 281 310 282 311 # Reset the extendable parts of WysiwygPlugin 283 %Foswiki::Plugins::WysiwygPlugin::xmltag = ();312 %Foswiki::Plugins::WysiwygPlugin::xmltag = (); 284 313 %Foswiki::Plugins::WysiwygPlugin::xmltagPlugin = (); 285 314 286 315 # Test-specific setup 287 if ( exists $args->{setup}) {316 if ( exists $args->{setup} ) { 288 317 $args->{setup}->(); 289 318 } … … 302 331 303 332 # Test-specific cleanup 304 if ( exists $args->{cleanup}) {333 if ( exists $args->{cleanup} ) { 305 334 $args->{cleanup}->(); 306 335 }
Note: See TracChangeset
for help on using the changeset viewer.
