summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2015-07-15 05:13:44 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-07-15 07:09:36 (GMT)
commitf97542b428b1a008e2df955cf2047e4b6b9d73d3 (patch) (side-by-side diff)
tree58fd02b5f62f7b08b21fa2749c9ae5a3a693eaa2
parent4097896542f2279700794104c7c0728beed38cd0 (diff)
downloadwit-f97542b428b1a008e2df955cf2047e4b6b9d73d3.tar.gz
wit-f97542b428b1a008e2df955cf2047e4b6b9d73d3.tar.bz2
Fix parsing of <nowiki> blocks.
* wikimarkup.py (tokread): Catch the </nowiki> tag appearing on the same line with the opening <nowiki>. Never return nowiki block as a tag, instead yield a sequence of TEXT nodes. * wiki2html.py (str_tag): Update. * wiki2texi.py: Likewise. * wiki2text.py: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--wiki2html.py4
-rw-r--r--wiki2texi.py4
-rw-r--r--wiki2text.py4
-rw-r--r--wikimarkup.py24
4 files changed, 18 insertions, 18 deletions
diff --git a/wiki2html.py b/wiki2html.py
index f3ea0e3..10a3e1b 100644
--- a/wiki2html.py
+++ b/wiki2html.py
@@ -173,9 +173,7 @@ class HtmlWikiMarkup (WikiMarkup):
return string
def str_tag(self, elt):
- if elt['tag'] == 'nowiki':
- return '<pre>' + self.format(elt['content']) + '</pre>'
- elif elt['tag'] == 'code':
+ if elt['tag'] == 'code':
self.nested += 1
s = self.format(elt['content'])
self.nested -= 1
diff --git a/wiki2texi.py b/wiki2texi.py
index e9009ec..3d74f80 100644
--- a/wiki2texi.py
+++ b/wiki2texi.py
@@ -120,9 +120,7 @@ class TexiWikiMarkup (WikiMarkup):
return str(elt)
def str_tag(self, elt):
- if elt['tag'] == 'nowiki':
- return '@example\n' + self.format(elt['content']) + '@end example\n'
- elif elt['tag'] == 'code':
+ if elt['tag'] == 'code':
self.nested += 1
s = self.format(elt['content'])
self.nested -= 1
diff --git a/wiki2text.py b/wiki2text.py
index d4cab81..c92dbc0 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -143,9 +143,7 @@ class TextWikiMarkup (WikiMarkup):
return output + linebuf
def str_tag(self, elt):
- if elt['tag'] == 'nowiki':
- return self.format(elt['content'])
- elif elt['tag'] == 'code':
+ if elt['tag'] == 'code':
self.nested += 1
s = self.format(elt['content'])
self.nested -= 1
diff --git a/wikimarkup.py b/wikimarkup.py
index 0c6d2f2..815e89d 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -234,27 +234,33 @@ class BaseWikiMarkup(object):
'content': line[pos:] })
if t:
+ line = rest
+ pos = 0
if t['type'] == 'OTAG' and t['tag'] == 'nowiki':
- s = ''
- if not m.group('closed'):
+ if m.group('closed'):
+ pass
+ else:
while 1:
try:
- l = self.input()
- m = ctag.match(l)
+ m = ctag.match(line)
if m and m.group('tag') == t['tag']:
+ yield({ 'type': 'TEXT',
+ 'content': m.group('pfx') })
+ pos = m.end(0)
break
- s += l
+
+ yield({ 'type': 'TEXT',
+ 'content': line })
+
+ line = self.input()
except StopIteration:
break
- t['type'] = 'TAG'
- t['content'] = {'type': 'TEXT', 'content': s}
+ continue
yield(t)
if t['type'] == 'OTAG' and m.group('closed'):
t['type'] = 'CTAG'
yield(t)
- line = rest
- pos = 0
else:
line = None

Return to:

Send suggestions and report system problems to the System administrator.