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)


  • 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


  • 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>
  • 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

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2003-04-20 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.