1<?php
2/**
3 * DokuWiki Plugin publist (Sanitiser Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Jorge Juan <jjchico@gmail.com>
7 * @author  Hans-Nikolai Viessmann <hans AT viess.mn>
8 */
9
10// Simple latex to utf8 sanitiser. Extend as needed.
11
12// Rename (or copy) this file to "sanitiser.php" and it will be automatically
13// used by publist.
14
15$sanitiser = function ($inputstr) {
16    $search_array = array(
17        '\$', '\&', '\%', '\#', '\_', '\{', '\}',   // specials
18        '{', '}',                                   // emphasizers
19        "\'a", "\'e", "\'i", "\'o", "\'u",      // acute
20        "\'A", "\'E", "\'I", "\'O", "\'U",
21        '\`a', '\`e', '\`i', '\`o', '\`u',      // grave
22        '\`A', '\`E', '\`I', '\`O', '\`U',
23        '\^a', '\^e', '\^i', '\^o', '\^u',      // circumflex
24        '\^A', '\^E', '\^I', '\^O', '\^U',
25        '\"a', '\"e', '\"i', '\"o', '\"u',      // umlaut
26        '\"A', '\"E', '\"I', '\"O', '\"U',
27        '\vc', '\vs',
28        "\'y",
29        '\~a', '\~A', '\~e', '\~E', '\~i',      // tilde
30        '\~I', '\~n', '\~N', '\~o', '\~O',
31        '\~u', '\~U',
32        '\cc', '\cC',
33        '~', '\,', '\\'                         // space
34    );
35    $replace_array = array(
36        '$', '&', '%', '#', '_', '<html>&#123;</html>', '<html>&#125;</html>',
37        '','',
38        'á', 'é', 'í', 'ó', 'ú',
39        'Á', 'É', 'Í', 'Ó', 'Ú',
40        'à', 'è', 'ì', 'ò', 'ù',
41        'À', 'È', 'Ì', 'Ò', 'Ù',
42        'â', 'ê', 'î', 'ô', 'û',
43        'Â', 'Ê', 'Î', 'Ô', 'Û',
44        'ä', 'ë', 'ï', 'ö', 'ü',
45        'Ä', 'Ë', 'Ï', 'Ö', 'Ü',
46        'č', 'š',
47        'ý',
48        'ã', 'Ã', 'ẽ', 'Ẽ', 'ĩ',
49        'Ĩ', 'ñ', 'Ñ', 'õ', 'Õ',
50        'ũ', 'Ũ',
51        'ç', 'Ç',
52        "\xC2\xA0", ' ', ' '
53    );
54    $outputstr = str_replace($search_array, $replace_array, $inputstr);
55    return $outputstr;
56}
57
58// vim:ts=4:sw=4:et:
59?>
60