diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-07-12 23:11:40 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-07-12 23:11:40 +0300 |
commit | 28072898f1bd9a925d73ac187d560198d6345524 (patch) | |
tree | a46d781fb85d9dda61fc8f68e0ba6ec43d60ce55 /wiki2text.py | |
parent | 75672b57a2d63f01d00795fe8d661d1efe7b6e8d (diff) | |
download | wikitrans-28072898f1bd9a925d73ac187d560198d6345524.tar.gz wikitrans-28072898f1bd9a925d73ac187d560198d6345524.tar.bz2 |
Improve tag handling and debugging
* wikimarkup.py: Rewrite tag recognition.
Implement dump method.
* wikicvt.py: New options -D (--dump), and -t dump
* wiki2html.py (input_tag): Remove method
(str_tag): Change handling of tags
* wiki2texi.py: Likewise.
* wiki2text.py: Likewise.
Diffstat (limited to 'wiki2text.py')
-rw-r--r-- | wiki2text.py | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/wiki2text.py b/wiki2text.py index 27a7051..d4cab81 100644 --- a/wiki2text.py +++ b/wiki2text.py | |||
@@ -142,25 +142,20 @@ class TextWikiMarkup (WikiMarkup): | |||
142 | length += wsc + wlen | 142 | length += wsc + wlen |
143 | return output + linebuf | 143 | return output + linebuf |
144 | 144 | ||
145 | supported_tags = [ 'nowiki', 'code' ] | ||
146 | def input_tag(self, tag): | ||
147 | return tag['tag'] in self.supported_tags | ||
148 | |||
149 | def str_tag(self, elt): | 145 | def str_tag(self, elt): |
150 | if elt['tag'] == 'nowiki': | 146 | if elt['tag'] == 'nowiki': |
151 | return elt['content'] | 147 | return self.format(elt['content']) |
152 | elif elt['tag'] == 'code': | 148 | elif elt['tag'] == 'code': |
153 | kwdict = { | 149 | self.nested += 1 |
154 | 'nested': self.nested + 1, | 150 | s = self.format(elt['content']) |
155 | 'lang': self.lang, | 151 | self.nested -= 1 |
156 | 'text': elt['content'], | 152 | return s #FIXME |
157 | 'html_base': self.html_base, | 153 | else: |
158 | 'image_base': self.image_base, | 154 | s = '<' + elt['tag'] |
159 | 'media_base': self.media_base } | 155 | if elt['args']: |
160 | markup = TextWiktionaryMarkup(**kwdict) | 156 | s += ' ' + elt['args'] |
161 | markup.debug_level = self.debug_level | 157 | s += '>' + self.format(elt['content']) + '</' + elt['tag'] + '>' |
162 | markup.parse() | 158 | return s |
163 | return str(markup) | ||
164 | 159 | ||
165 | def format(self, elt): | 160 | def format(self, elt): |
166 | if elt['type'] == 'TEXT': | 161 | if elt['type'] == 'TEXT': |