diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-11-26 23:56:26 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-11-26 23:56:32 +0200 |
commit | 34268ebe03133b799208da261dbdbf7c0fb40b93 (patch) | |
tree | 355c58a6d9a8325ff1d395b6dadff2cec8013271 /build-aux | |
parent | 67cd79c3c64d6dfe73ff5dd80ba51d0bf9267b04 (diff) | |
download | wikitrans-34268ebe03133b799208da261dbdbf7c0fb40b93.tar.gz wikitrans-34268ebe03133b799208da261dbdbf7c0fb40b93.tar.bz2 |
Fix HTML generation.
* wikins.py: New file (automatically generated.)
* build-aux/extrns.php: New file (generator for the above).
* wiki2html.py (HtmlWikiMarkup.image_kw, target): Remove
(wiki_ns_name,link,mktgt): New methods.
(str_link,str_tmpl): Rewrite using self.link.
* wiki2text.py, wikimarkup.py (__init__): Fix handling of multiple keywords.
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/extrns.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/build-aux/extrns.php b/build-aux/extrns.php new file mode 100644 index 0000000..e2e8c4f --- /dev/null +++ b/build-aux/extrns.php | |||
@@ -0,0 +1,71 @@ | |||
1 | <?php | ||
2 | $nss = array(); | ||
3 | $ns_res = array(); | ||
4 | function select_ns($file, $lang) | ||
5 | { | ||
6 | global $nss, $ns_res; | ||
7 | |||
8 | include($file); | ||
9 | if (isset($namespaceNames)) { | ||
10 | array_push($nss, $lang); | ||
11 | printf("wiki_ns_%s = {\n", $lang); | ||
12 | $reg = array(); | ||
13 | foreach ($namespaceNames as $ns => $val) { | ||
14 | if ($val == '') | ||
15 | continue; | ||
16 | if (preg_match('/(.*)\$1(.*)/', $val, $matches)) | ||
17 | array_push($reg, | ||
18 | array($matches[1], $matches[2], | ||
19 | $ns)); | ||
20 | else | ||
21 | printf(" \"%s\": \"%s\",\n", $val, $ns); | ||
22 | } | ||
23 | print "}\n"; | ||
24 | if (count($reg)) { | ||
25 | array_push($ns_res, $lang); | ||
26 | printf("wiki_ns_re_%s = [\n", $lang); | ||
27 | foreach ($reg as $val) { | ||
28 | printf(" (\"%s\", \"%s\", \"%s\"),\n", | ||
29 | $val[0], $val[1], $val[2]); | ||
30 | } | ||
31 | print "]\n"; | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
36 | |||
37 | function process_dir($dir) | ||
38 | { | ||
39 | if (!($dp = opendir ($dir))) | ||
40 | die ("Can't open data directory."); | ||
41 | while ($name = readdir ($dp)) { | ||
42 | if (preg_match('|.*/?Messages([A-Z][a-z_-]+).php|', $name, $matches)) { | ||
43 | $lang = strtolower($matches[1]); | ||
44 | #print "$lang\n"; | ||
45 | select_ns($name, $lang); | ||
46 | } | ||
47 | |||
48 | } | ||
49 | closedir ($dp); | ||
50 | } | ||
51 | |||
52 | echo "# This file is generated automatically. Do not edit.\n"; | ||
53 | echo "# -*- coding: utf-8 -*-\n"; | ||
54 | process_dir("."); | ||
55 | |||
56 | print "wiki_ns = {\n"; | ||
57 | if (count($nss)) { | ||
58 | foreach ($nss as $lang) | ||
59 | printf(" \"%s\": wiki_ns_%s,\n", $lang, $lang); | ||
60 | } | ||
61 | print "}\n"; | ||
62 | |||
63 | print "wiki_ns_re = {\n"; | ||
64 | if (count($ns_res)) { | ||
65 | foreach ($nss as $lang) | ||
66 | printf(" \"%s\": wiki_ns_re_%s,\n", $lang, $lang); | ||
67 | } | ||
68 | print "}\n"; | ||
69 | |||
70 | |||
71 | ?> | ||