/[drupal]/contributions/modules/customfilter/customfilter_sample.xml
ViewVC logotype

Contents of /contributions/modules/customfilter/customfilter_sample.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Oct 24 14:00:04 2007 UTC (2 years, 1 month ago) by arhip
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +25 -21 lines
File MIME type: text/xml
Fixing TOC bug when there is no heading at all
1 <?xml version="1.0" standalone="yes"?>
2 <customfilter>
3 <filterset name="Drupal Uppercase">
4 <description>Change every occurence of "drupal" into bold "DRUPAL"</description>
5 <tips>
6 <short><![CDATA[Change every occurence of "drupal" into bold "DRUPAL"]]></short>
7 <long><![CDATA[Change every occurence of "drupal" into bold "DRUPAL"]]></long>
8 </tips>
9 <filters>
10 <filter name="Uppercase" matches="0" func="0" weight="0">
11 <description><![CDATA[Converts "dRupAl" into <strong>DRUPAL</strong>]]></description>
12 <pattern><![CDATA[/(drupal)/i]]></pattern>
13 <replacement><![CDATA[<strong>DRUPAL</strong>]]></replacement>
14 </filter>
15 </filters>
16 </filterset>
17 <filterset name="Footnotes">
18 <description>Use footnotes</description>
19 <tips>
20 <short><![CDATA[You can use $fn[...] to insert footnotes.]]></short>
21 <long><![CDATA[You can use $fn[...] to insert footnotes.]]></long>
22 </tips>
23 <filters>
24 <filter name="Footnotes" matches="0" func="1" weight="-9">
25 <description><![CDATA[Collect footnotes enclosed with $fn[...]]]></description>
26 <pattern><![CDATA[/\$fn\[((.|\n)*?)\]/i]]></pattern>
27 <replacement><![CDATA[if (! isset($vars->fncount)) $vars->fncount = 0;
28
29 $vars->fncount ++;
30 $vars->fn[$vars->fncount] = $matches[1];
31
32 return "<sup><a href=\"#fn{$vars->fncount}\">{$vars->fncount}</a></sup>" ;]]></replacement>
33 </filter>
34 <filter name="Generate Footnotes" matches="0" func="1" weight="-9">
35 <description><![CDATA[Generate footnotes collected at the end of the text]]></description>
36 <pattern><![CDATA[/$/]]></pattern>
37 <replacement><![CDATA[if (isset($vars->fn) && is_array($vars->fn)) {
38 $text = "<ol class=\"footnotes\">";
39 foreach ($vars->fn as $index => $fn) {
40 $text .= "<li><a name=\"fn{$index}\">{$fn}</a></li>";
41 }
42 $text .= "</ol>";
43 }
44
45 return $text;]]></replacement>
46 </filter>
47 </filters>
48 </filterset>
49 <filterset name="MediaWiki">
50 <description>Allows user to use MediaWiki syntax (incomplete).</description>
51 <tips>
52 <short><![CDATA[You can use MediaWiki syntax (incomplete).]]></short>
53 <long><![CDATA[You can use MediaWiki syntax. This filter is for demonstration purpose only, not a complete mediawiki parser.
54
55 <table>
56 <thead>
57 <th>You write</th>
58 <th>You get</th>
59 </thead>
60 <tbody>
61 <tr>
62 <td>''italic''</td>
63 <td><em>italic</em></td>
64 </tr>
65 <tr>
66 <td>'''bold'''</td>
67 <td><strong>bold</strong></td>
68 </tr>
69 <tr>
70 <td>'''''bold-italic'''''</td>
71 <td><strong><em>bold-italic</em></strong></td>
72 </tr>
73 <tr>
74 <td>=Heading 1=<br/>==Heading 2==<br/>===Heading 3===</td>
75 <td><h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3></td>
76 </tr>
77 <tr>
78 <td>(space)some preformatted text</td>
79 <td><pre>some preformatted text</pre></td>
80 </tr>
81 <tr>
82 <td>[http://drupal.org Drupal]</td>
83 <td><a href="http://drupal.org">Drupal</a></td>
84 </tr>
85 <tr>
86 <td>* List 1<br/>* List 2<br/>** List 2.1</br/></td>
87 <td><ul><li>List 1</li><li>List 2<ul><li>List 2.1</li></ul></li></ul></td>
88 </tr>
89 <tr>
90 <td># List 1<br/># List 2<br/>## List 2.1</br/></td>
91 <td><ol><li>List 1</li><li>List 2<ol><li>List 2.1</li></ol></li></ol></td>
92 </tr>
93 </tbody>
94 </table>]]></long>
95 </tips>
96 <filters>
97 <filter name="Bold-italic" matches="0" func="0" weight="-7">
98 <description><![CDATA[Converts '''''abc''''' into <strong><em>abc</em></strong>]]></description>
99 <pattern><![CDATA[/'''''(.*?)'''''/]]></pattern>
100 <replacement><![CDATA[<strong><em>$1</em></strong>]]></replacement>
101 </filter>
102 <filter name="Bold" matches="0" func="0" weight="-6">
103 <description><![CDATA[Converts '''abc''' into <strong>abc</strong>]]></description>
104 <pattern><![CDATA[/'''(.*?)'''/]]></pattern>
105 <replacement><![CDATA[<strong>$1</strong>]]></replacement>
106 </filter>
107 <filter name="Italic" matches="0" func="0" weight="-5">
108 <description><![CDATA[Converts ''abc'' into <em>abc</em>]]></description>
109 <pattern><![CDATA[/''(.*?)''/]]></pattern>
110 <replacement><![CDATA[<em>$1</em>]]></replacement>
111 </filter>
112 <filter name="Headings" matches="0" func="1" weight="0">
113 <description><![CDATA[Converts =ABC= to <h1>ABC</h1>]]></description>
114 <pattern><![CDATA[/^(\={1,9})(.*?)(\={1,9})$/m]]></pattern>
115 <replacement><![CDATA[$len = strlen($matches[1]);
116
117 $result = $matches[2];
118 if (strlen($matches[3]) == $len) {
119 $anchor = count($vars->headings);
120
121 $vars->headings[] = array(
122 'level' => $len,
123 'text' => $result,
124 'anchor' => $anchor,
125 );
126
127 $result = "<h$len><a name=\"$anchor\">$result</a></h$len>";
128 }
129
130 return $result;]]></replacement>
131 </filter>
132 <filter name="Unordered list" matches="0" func="0" weight="1">
133 <description><![CDATA[]]></description>
134 <pattern><![CDATA[/((^(\*+)(.*?)\n)+)/m]]></pattern>
135 <replacement><![CDATA[$1]]></replacement>
136 <subfilters>
137 <filter name="List item" matches="1" func="1" weight="0">
138 <description><![CDATA[]]></description>
139 <pattern><![CDATA[/^(\*+)(.*?)$/m]]></pattern>
140 <replacement><![CDATA[$result = '';
141
142 $level = strlen($matches[1]);
143
144 if ($vars->lastlevel < $level) {
145 for ($i = $vars->lastlevel; $i < $level; $i++) {
146 $result .= '<ul>';
147 }
148 }
149 elseif ($vars->lastlevel > $level) {
150 for ($i = $vars->lastlevel; $i > $level; $i--) {
151 $result .= '</li></ul>';
152 }
153 }
154 else {
155 $result .= '</li>';
156 }
157
158 $result .= "<li>{$matches[2]}";
159
160 $vars->lastlevel = $level;
161
162 return $result;]]></replacement>
163 </filter>
164 <filter name="Close list" matches="1" func="1" weight="3">
165 <description><![CDATA[]]></description>
166 <pattern><![CDATA[/$/]]></pattern>
167 <replacement><![CDATA[$result = '';
168
169 if ($vars->lastlevel > 0) {
170 for ($i = 0; $i < $vars->lastlevel; $i++)
171 $result .= '</li></ul>';
172
173 $vars->lastlevel = 0;
174 }
175
176 return $result;]]></replacement>
177 </filter>
178 </subfilters>
179 </filter>
180 <filter name="Ordered List" matches="0" func="0" weight="1">
181 <description><![CDATA[]]></description>
182 <pattern><![CDATA[/((^(\#+)(.*?)\n)+)/m]]></pattern>
183 <replacement><![CDATA[$1]]></replacement>
184 <subfilters>
185 <filter name="List Item" matches="1" func="1" weight="0">
186 <description><![CDATA[]]></description>
187 <pattern><![CDATA[/^(\#+)(.*?)$/m]]></pattern>
188 <replacement><![CDATA[$result = '';
189
190 $level = strlen($matches[1]);
191
192 if ($vars->lastlevel < $level) {
193 for ($i = $vars->lastlevel; $i < $level; $i++) {
194 $result .= '<ol>';
195 }
196 }
197 elseif ($vars->lastlevel > $level) {
198 for ($i = $vars->lastlevel; $i > $level; $i--) {
199 $result .= '</li></ol>';
200 }
201 }
202 else {
203 $result .= '</li>';
204 }
205
206 $result .= "<li>{$matches[2]}";
207
208 $vars->lastlevel = $level;
209
210 return $result;]]></replacement>
211 </filter>
212 <filter name="Close list" matches="1" func="1" weight="3">
213 <description><![CDATA[]]></description>
214 <pattern><![CDATA[/$/]]></pattern>
215 <replacement><![CDATA[$result = '';
216
217 if ($vars->lastlevel > 0) {
218 for ($i = 0; $i < $vars->lastlevel; $i++)
219 $result .= '</li></ol>';
220
221 $vars->lastlevel = 0;
222 }
223
224 return $result;]]></replacement>
225 </filter>
226 </subfilters>
227 </filter>
228 <filter name="Preformatted" matches="0" func="0" weight="5">
229 <description><![CDATA[Preformatted text]]></description>
230 <pattern><![CDATA[/((^\x20+(.*?)\n)+)/m]]></pattern>
231 <replacement><![CDATA[<pre>$1</pre>]]></replacement>
232 </filter>
233 <filter name="Link" matches="0" func="1" weight="7">
234 <description><![CDATA[Converts [http://drupal.org Drupal] into <a href="drupal.org">Drupal</a>]]></description>
235 <pattern><![CDATA[/\[\x20*(\S*?)(\x20+(.*?))?\]/]]></pattern>
236 <replacement><![CDATA[$link = $matches[1];
237 $text = $matches[3];
238
239 if ($text == '') {
240 $text = $link;
241 }
242
243 return "<a href=\"$link\">$text</a>";]]></replacement>
244 </filter>
245 <filter name="TOC" matches="0" func="1" weight="10">
246 <description><![CDATA[Table of Contents]]></description>
247 <pattern><![CDATA[/^/]]></pattern>
248 <replacement><![CDATA[if (is_array($vars->headings) && count($vars->headings) > 0) {
249 $result = '<div>';
250 $result .= '<h2>Table of contents</h2>';
251
252 $lastlevel = 0;
253 foreach ($vars->headings as $heading) {
254 if ($heading['level'] > $lastlevel) {
255 for ($i = $heading['level']; $i > $lastlevel; $i--) {
256 $result .= '<ol>';
257 }
258 }
259 elseif ($heading['level'] < $lastlevel) {
260 for ($i = $heading['level']; $i < $lastlevel; $i++) {
261 $result .= '</li></ol>';
262 }
263 }
264 else {
265 $result .= '</li>';
266 }
267
268 $result .= "<li><a href=\"#{$heading['anchor']}\">{$heading['text']}</a>";
269 $lastlevel = $heading['level'];
270 }
271
272 for ($i = 0; $i < $lastlevel; $i++)
273 $result .= '</li></ol>';
274
275 $result .= '</div>';
276 }
277 else
278 $result = '';
279
280 return $result;]]></replacement>
281 </filter>
282 </filters>
283 </filterset>
284 </customfilter>

  ViewVC Help
Powered by ViewVC 1.1.2