Changeset 3992 for trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
- Timestamp:
- 05/30/09 15:46:14 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
r3947 r3992 35 35 36 36 use vars qw( $html2tml $tml2html $recursionBlock $imgMap ); 37 use vars qw( %TWikiCompatibility @refs );37 use vars qw( %TWikiCompatibility @refs %xmltag %xmltagPlugin); 38 38 39 39 our $SHORTDESCRIPTION = 'Translator framework for Wysiwyg editors'; … … 434 434 435 435 if ( $web && $web ne $opts->{web} ) { 436 print STDERR "$orig -> $web+$topic$anchor\n"; #debug 436 437 #print STDERR "$orig -> $web+$topic$anchor\n"; #debug 437 438 return $web . '.' . $topic . $anchor; 438 439 } … … 548 549 } 549 550 551 =pod 552 553 ---++ ObjectMethod addXMLTag($tag, \&fn) 554 555 Instruct WysiwygPlugin to "lift out" the named tag 556 and pass it to &fn for processing. 557 &fn may modify the text of the tag. 558 &fn should return 0 is the tag is to be re-embedded immediately, 559 or 1 if it is to be re-embedded after all processing is complete. 560 The text passed (by reference) to &fn includes the 561 =<tag> ... </tag>= brackets. 562 563 A plugin may call this function more than once 564 e.g. to change the processing function for a tag. 565 However, only the *original plugin* may change the processing 566 for a tag. 567 568 =cut 569 570 sub addXMLTag { 571 my ( $tag, $fn ) = @_; 572 573 my $plugin = caller; 574 $plugin =~ s/^Foswiki::Plugins:://; 575 576 return if not defined $tag; 577 578 if ( ( not exists $xmltag{$tag} and not exists $xmltagPlugin{$tag} ) 579 or ( $xmltagPlugin{$tag} eq $plugin ) ) 580 { 581 582 # This is either a plugin adding a new tag 583 # or a plugin adding a tag it had previously added before. 584 # A plugin is allowed to add a tag that it had added before 585 # and the new function replaces the old. 586 # 587 $fn = sub { 1 } 588 unless $fn; # Default function 589 590 $xmltag{$tag} = $fn; 591 $xmltagPlugin{$tag} = $plugin; 592 } 593 else { 594 595 # DON'T replace the existing processing for this tag 596 printf STDERR "WysiwygPlugin::addXMLTag: " 597 . "$plugin cannot add XML tag $tag, " 598 . "that tag was already registered by $xmltagPlugin{$tag}\n"; 599 } 600 } 601 550 602 sub TranslateTML2HTML { 551 603 my ( $text, $web, $topic ) = @_; … … 563 615 getViewUrl => \&getViewUrl, 564 616 expandVarsInURL => \&expandVarsInURL, 617 xmltag => \%xmltag, 565 618 } 566 619 );
Note: See TracChangeset
for help on using the changeset viewer.
