1 [[meta title="sar (third party plugin)" ]]
2 [[template id=plugin name=sar author="[[VictorMoral]]"]]
3 [[tag type/chrome type/slow ]]
5 The `sar` plugin is useful to make global or local search and replace operations
6 using common or specific terms.
8 The characteristics are:
10 - Support for a global dictionary page (optional but recommended).
11 - Is possible to replace the first appearance with a text and the rest with
13 - Support for enable or disable sar engine in any page.
14 - Support for disable sar engine on any term in any page.
16 The global dictionary page is like this:
20 - [[sar search="ikiwiki" first="[IkiWiki](http://ikiwiki.info)" next="_IkiWiki_"]]
21 - [[sar search="debian" first="[Debian](http://debian.org)" next="_Debian_"]]
22 - [[sar search="perl" first="[Perl](http://perl.org)" next="_Perl_"]]
23 - [[sar search="linux" replace="GNU/Linux"]]
26 - [[sar search="joey" first="[Joey Hess](http://ikiwiki.info/users/joey]]" next="_Joey_" ]]
27 - [[sar search="angel" first="[Angel](http://triptico.com)" next="Angel"]]
31 - [[sar search="smtp" first="\[[wp SMTP]]" next="‘SMTP‘"]]
32 - [[sar search="pop3" first="\[[wp POP3]]" next="’POP3’"]]
34 The search parameter is a literal text; later will be used as part of the
35 final regular expression.
37 A _search and replace_ directive has the following parameters:
39 - `search`: define the text to search.
40 - `first`: define the replace text in the first match.
41 - `next`: define the replace text in all matches except the first.
42 - `replace`: define the replace text in all matches.
43 - `disable`: disable the sar plugin in the current page or the current term if
44 there is a search parameter.
48 The plugin need the following global values:
50 - `sar_mainpage`: define the global dictionary page. The default value is `sar`.
51 - `sar_pagespec`: enable the plugin with a selection of pages. The default
52 value is `*`, but a recommended value is `link(tag/sar)`.
56 This plugin works as a filter hook on the source markdown text; the dictionary
57 terms must be carefully selected, because they could interfere with URLs and
58 other preprocessor directives.
60 The code is highly experimental and the author will appreciate any help with
61 his development or his english. I'm using at my site with minor problems.
65 In a ikiwiki source page we can write this
69 for enable the sar plugin in this page or
73 for disable the sar plugin or
75 \[[sar search=debian replace="__Debian__"]]
77 to define a global replace for the term `debian` or
79 \[[sar search=ibm first=’[IBM](http://www.ibm.com)’
82 to define a replace for the first match of the string `ibm` and a different
83 replace for the rest, and
86 \[[sar search=hp disable=1]]
88 to disable the sar plugin in the current page for the term `hp`.
94 - Minor bugfixes in the pages selection.
95 - Call to add_depends() for every page filtered
99 - This is the first functional version.
103 The module can be downloaded from:
105 - [My personal site](http://taquiones.net/files/misc)
106 - [My personal Debian repository](http://taquiones.net/files/debian)