Changeset 4295


Ignore:
Timestamp:
06/24/09 21:13:57 (3 years ago)
Author:
MichaelTempest
Message:

Item1770: Update documentation; add more unit tests

Location:
trunk/WysiwygPlugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WysiwygPlugin/data/System/WysiwygPlugin.txt

    r4051 r4295  
    137137Plugins that extend the syntax using macros, such as =%MYMACRO%=, should work fine. 
    138138 
    139 *Implementors note* plugins that use XML-like tags may call Foswiki::Plugins::WysiwygPlugin::addXMLTag() to make WysiwygPlugin protect the content between XML-like tags, just like it does for macros.  
     139*Implementors note* plugins that use XML-like tags may call [[%SCRIPTURLPATH{view}%/%SYSTEMWEB%/PerlDoc?module=Foswiki::Plugins::WysiwygPlugin][Foswiki::Plugins::WysiwygPlugin::addXMLTag()]] from their =initPlugin= handlers to make WysiwygPlugin protect the content between XML-like tags, just like it does for macros.  
    140140 
    141141---+++ Overlapping styles 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm

    r4144 r4295  
    551551=pod 
    552552 
    553 ---++ Function addXMLTag($tag, \&fn) 
     553---++ StaticMethod addXMLTag($tag, \&fn) 
    554554 
    555555Instruct WysiwygPlugin to "lift out" the named tag  
    556556and pass it to &fn for processing. 
    557557&fn may modify the text of the tag. 
    558 &fn should return 0 is the tag is to be re-embedded immediately, 
     558&fn should return 0 if the tag is to be re-embedded immediately, 
    559559or 1 if it is to be re-embedded after all processing is complete. 
    560560The text passed (by reference) to &fn includes the  
    561561=<tag> ... </tag>= brackets. 
     562 
     563The simplest use of this function is something like this: 
     564=Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'mytag', sub { 1 } );= 
    562565 
    563566A plugin may call this function more than once  
     
    565568However, only the *original plugin* may change the processing 
    566569for a tag. 
     570 
     571Plugins should call this function from their =initPlugin= 
     572handlers so that WysiwygPlugin will protect the XML-like tags 
     573for all conversions, including REST conversions. 
     574Plugins that are intended to be used with older versions of Foswiki 
     575(e.g. 1.0.6) should check that this function is defined before calling it, 
     576so that they degrade gracefully if an older version of WysiwygPlugin 
     577(e.g. that shipped with 1.0.6) is installed. 
    567578 
    568579=cut 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm

    r4294 r4295  
    117117            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    118118                sub { 1 } ); 
     119        }, 
     120        html => '<p>' 
     121          . $protecton 
     122          . '&lt;customtag&gt;some&nbsp;&gt;&nbsp;&nbsp;text&lt;/customtag&gt;' 
     123          . $protectoff . '</p>', 
     124        tml => '<customtag>some >  text</customtag>', 
     125    }, 
     126    { 
     127        exec  => $TML2HTML | $ROUNDTRIP, 
     128        name  => 'CustomXmlTagCallbackChangesText', 
     129        setup => sub { 
     130            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
     131                sub { $_[0] =~ s/some/different/; return 1; } ); 
     132        }, 
     133        html => '<p>' 
     134          . $protecton 
     135          . '&lt;customtag&gt;different&nbsp;&gt;&nbsp;&nbsp;text&lt;/customtag&gt;' 
     136          . $protectoff . '</p>', 
     137        tml      => '<customtag>some >  text</customtag>', 
     138        finaltml => '<customtag>different >  text</customtag>', 
     139    }, 
     140    { 
     141        exec  => $TML2HTML | $ROUNDTRIP, 
     142        name  => 'CustomXmlTagDefaultCallback', 
     143        setup => sub { 
     144            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag' ); 
    119145        }, 
    120146        html => '<p>' 
Note: See TracChangeset for help on using the changeset viewer.