Changeset 4295
- Timestamp:
- 06/24/09 21:13:57 (3 years ago)
- Location:
- trunk/WysiwygPlugin
- Files:
-
- 3 edited
-
data/System/WysiwygPlugin.txt (modified) (1 diff)
-
lib/Foswiki/Plugins/WysiwygPlugin.pm (modified) (2 diffs)
-
test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/data/System/WysiwygPlugin.txt
r4051 r4295 137 137 Plugins that extend the syntax using macros, such as =%MYMACRO%=, should work fine. 138 138 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. 140 140 141 141 ---+++ Overlapping styles -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
r4144 r4295 551 551 =pod 552 552 553 ---++ FunctionaddXMLTag($tag, \&fn)553 ---++ StaticMethod addXMLTag($tag, \&fn) 554 554 555 555 Instruct WysiwygPlugin to "lift out" the named tag 556 556 and pass it to &fn for processing. 557 557 &fn may modify the text of the tag. 558 &fn should return 0 i sthe tag is to be re-embedded immediately,558 &fn should return 0 if the tag is to be re-embedded immediately, 559 559 or 1 if it is to be re-embedded after all processing is complete. 560 560 The text passed (by reference) to &fn includes the 561 561 =<tag> ... </tag>= brackets. 562 563 The simplest use of this function is something like this: 564 =Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'mytag', sub { 1 } );= 562 565 563 566 A plugin may call this function more than once … … 565 568 However, only the *original plugin* may change the processing 566 569 for a tag. 570 571 Plugins should call this function from their =initPlugin= 572 handlers so that WysiwygPlugin will protect the XML-like tags 573 for all conversions, including REST conversions. 574 Plugins 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, 576 so that they degrade gracefully if an older version of WysiwygPlugin 577 (e.g. that shipped with 1.0.6) is installed. 567 578 568 579 =cut -
trunk/WysiwygPlugin/test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm
r4294 r4295 117 117 Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 118 118 sub { 1 } ); 119 }, 120 html => '<p>' 121 . $protecton 122 . '<customtag>some > text</customtag>' 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 . '<customtag>different > text</customtag>' 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' ); 119 145 }, 120 146 html => '<p>'
Note: See TracChangeset
for help on using the changeset viewer.
