Tags:
create new tag
, view all tags
Just a reminder for myself for a generic string replacement plugin ...

Rationale: put formatting rules in an editable topic (let call it WebPatterns and TWikiPatterns)

Implementation:

  • at plugin initialization:
    • collect all patterns from the topics (first TWikiPatterns, then WebPatterns)
    • avoid overriding patterns ( a' la FINALPREFERENCES )
    • compile them as pattern variables
    • if needed, for the efficiency-concerned, compile at runtime a subroutine that does all replacements
  • Instantiate a Safe container (see the Safe CPAN module) enabling some TWiki functions and vars:
    • &internalLink(), %handleIncludeFile() ...
    • $web, $topic, $username ...
  • in the outsidePreHandler apply (eval) the replacements inside the Safe container

Desirable side effects:

  • if the pattern specification is verbose enough we obtain automagically its documentation

Examples:

  • Double underscore -> bold italic
  • Old syntax of INCLUDE tag:
    • Pattern OldIncludePattern = /%INCLUDE:"([^%\"]*?)"%/&handleIncludeFile( $1, $topic, $web, $user )/geo

PS: I have used WikiNames for patterns so that we can document their syntax and examples

-- AndreaSterbini - 20 Feb 2001

I'm almost done with a dumb version of the above idea, you can just define patterns with the syntax

  • Replace <pattern> with <replacement>
Where:
  • the pattern is a normal regexp
  • the replacement is just a string where the symbols $1 .. $9 are replaced with the corresponding matching parts in the pattern.

-- AndreaSterbini - 21 Mar 2001

Topic revision: r4 - 2003-04-20 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by PerlIdeas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.