1 [[!template id=plugin name=sar author="[[VictorMoral]]"]]
2 [[!tag type/chrome type/slow ]]
4 The `sar` plugin is useful to make global or local search and replace operations
5 using common or specific terms.
7 The characteristics are:
9 - Support for a global dictionary page (optional but recommended).
10 - Is possible to replace the first appearance with a text and the rest with
13 The global dictionary page is like this:
17 - [[!sar search="ikiwiki" first="[IkiWiki](http://ikiwiki.info)" next="_IkiWiki_"]]
18 - [[!sar search="debian" first="[Debian](http://debian.org)" next="_Debian_"]]
19 - [[!sar search="perl" first="[Perl](http://perl.org)" next="_Perl_"]]
20 - [[!sar search="linux" replace="GNU/Linux"]]
23 - [[!sar search="joey" first="[Joey Hess](http://ikiwiki.info/users/joey]]" next="_Joey_" ]]
24 - [[!sar search="angel" first="[Angel](http://triptico.com)" next="Angel"]]
28 - [[!sar search="smtp" first="\[[!wp SMTP]]" next="‘SMTP‘"]]
29 - [[!sar search="pop3" first="\[[!wp POP3]]" next="’POP3’"]]
31 The search expressions must be surrounded by double dashes in a source ikiwiki
34 Mis programas están escritos en lenguaje --perl--, funcionando con el
35 sistema --debian--, y mis páginas web funcionan con --ikiwiki-- cuyo autor
38 --ikiwiki-- es un buen software.
40 After a filter operation the content is:
42 Mis programas están escritos en lenguaje [Perl](http://perl.org),
43 funcionando con el sistema [Debian](http://debian.org), y mis páginas web
44 funcionan con [IkiWiki](http://ikiwiki.info) cuyo autor es [Joey
45 Hess](http://ikiwiki.info/users/joey).
47 _IkiWiki_ es un buen software.
49 _Note_: I chose this syntax because don't clashes with markdown and it is easy to write.
51 A _search and replace_ directive has the following parameters:
53 - `search`: define the text to search.
54 - `first`: define the replace text in the first match.
55 - `next`: define the replace text in all matches except the first.
56 - `replace`: define the replace text in all matches.
58 Now the code is used at my site without problems, and the author will
59 appreciate any help with his development or his english.
63 The plugin need the following global values:
65 - `sar_mainpage`: define the global dictionary page. The default value is `sar`.
66 - `sar_pagespec`: enable the plugin with a selection of pages. The default
67 value is `*`, but a recommended value is `link(tag/sar)`.
71 In a ikiwiki source page we can write this
73 \[[!sar search=debian replace="__Debian__"]]
75 for define a global replace for the term `--debian--` or
77 \[[!sar search=ibm first=’[IBM](http://www.ibm.com)’
80 to define a replace for the first match of the string `--ibm--` and a different
87 - First functional version with the new sar expressions.
91 - New design for the search expressions.
95 - Minor bugfixes in the pages selection.
96 - Call to add_depends() for every page filtered
100 - This is the first functional version.
104 The module can be downloaded from:
106 - [My personal site](http://taquiones.net/files/misc)
107 - [My personal Debian repository](http://taquiones.net/files/debian)