diff options
-rw-r--r-- | WikiTrans/wikimarkup.py | 8 | ||||
-rw-r--r-- | testdata/headings.html | 6 | ||||
-rw-r--r-- | testdata/nowiki-ind.html | 5 | ||||
-rw-r--r-- | testdata/nowiki-ind.wiki | 9 | ||||
-rw-r--r-- | testdata/nowiki-tag.html | 1 | ||||
-rw-r--r-- | testdata/nowiki-tag.wiki | 1 | ||||
-rw-r--r-- | testdata/nowiki.html | 1 | ||||
-rw-r--r-- | testdata/nowiki.wiki | 1 | ||||
-rw-r--r-- | tests/test.py | 12 |
9 files changed, 36 insertions, 8 deletions
diff --git a/WikiTrans/wikimarkup.py b/WikiTrans/wikimarkup.py index d56c664..2fad0af 100644 --- a/WikiTrans/wikimarkup.py +++ b/WikiTrans/wikimarkup.py @@ -86,7 +86,7 @@ class TagAttributes(object): class BaseWikiMarkup(object): - delim = re.compile("^==+\s*|\s*==+\s*$|(^----$)|^\\*+|^#+|^[;:]+|(\\[\\[)|\\[|(\\{\\{)|(\\]\\])|\\]|(\\}\\})|\\||(\\'\\'\\'?)|<") + delim = re.compile("^==+[ \t]*|[ \t]*==+[ \t]*$|(^----$)|^\\*+|^#+|^[;:]+|(\\[\\[)|\\[|(\\{\\{)|(\\]\\])|\\]|(\\}\\})|\\||(\\'\\'\\'?)|<") otag = re.compile("<(?P<tag>[a-zA-Z0-9_]+)(?:\s+(?P<args>[^>]+))?\s*(?P<closed>/)?>") ctag = re.compile("</(?P<tag>[a-zA-Z0-9_]+)\s*>") refstart = re.compile("^https?://") @@ -667,7 +667,8 @@ class BaseWikiMarkup(object): if self.peektkn()['type'] == 'NL': break else: - self.dprint(80, "LEAVE parse_header=%s", "None") + self.dprint(80, "LEAVE parse_header=%s, tok=%s", + "None", self.peektkn()) return None else: x = self.parse_inline(tok) @@ -792,9 +793,6 @@ class BaseWikiMarkup(object): return ret def parse0(self): - if self.tokind == 0: - self.newline = True - return self.parse_para() tok = self.getkn() self.dprint(80, "ENTER parse0(%s)", tok) toktype = tok['type'] diff --git a/testdata/headings.html b/testdata/headings.html index 0ec26ac..4dd1203 100644 --- a/testdata/headings.html +++ b/testdata/headings.html @@ -1,9 +1,9 @@ -<h2> Section headings </h2> +<h2>Section headings</h2> <p><i>Headings</i> organize your writing into sections. The Wiki software can automatically -generate a <a href="http://pl.wiktionary.org/wiki/table%20of%20contents">table of contents</a> from them.</p><h3> Subsection </h3> -<p>Using more "equals" (=) signs creates a subsection.</p><h4> A smaller subsection </h4> +generate a <a href="http://pl.wiktionary.org/wiki/table%20of%20contents">table of contents</a> from them.</p><h3>Subsection</h3> +<p>Using more "equals" (=) signs creates a subsection.</p><h4>A smaller subsection</h4> <p>Don't skip levels, like from two to four equals signs.</p><p>Start with 2 equals signs not 1 diff --git a/testdata/nowiki-ind.html b/testdata/nowiki-ind.html new file mode 100644 index 0000000..b2bd72c --- /dev/null +++ b/testdata/nowiki-ind.html @@ -0,0 +1,5 @@ +<p>Para</p><pre> + a + b + c +</pre><p>para</p> diff --git a/testdata/nowiki-ind.wiki b/testdata/nowiki-ind.wiki new file mode 100644 index 0000000..9d315a0 --- /dev/null +++ b/testdata/nowiki-ind.wiki @@ -0,0 +1,9 @@ +Para + +<nowiki> + a + b + c +</nowiki> + +para diff --git a/testdata/nowiki-tag.html b/testdata/nowiki-tag.html new file mode 100644 index 0000000..58b96fc --- /dev/null +++ b/testdata/nowiki-tag.html @@ -0,0 +1 @@ +<p>A <tag></p>
\ No newline at end of file diff --git a/testdata/nowiki-tag.wiki b/testdata/nowiki-tag.wiki new file mode 100644 index 0000000..9aca78b --- /dev/null +++ b/testdata/nowiki-tag.wiki @@ -0,0 +1 @@ +A <<nowiki/>tag> diff --git a/testdata/nowiki.html b/testdata/nowiki.html new file mode 100644 index 0000000..346d0c3 --- /dev/null +++ b/testdata/nowiki.html @@ -0,0 +1 @@ +<p>#:version=1.0<i>rest</i> of line</p> diff --git a/testdata/nowiki.wiki b/testdata/nowiki.wiki new file mode 100644 index 0000000..6c7833c --- /dev/null +++ b/testdata/nowiki.wiki @@ -0,0 +1 @@ +<nowiki>#:version=1.0</nowiki>''rest'' of line diff --git a/tests/test.py b/tests/test.py index cde21bc..c54a717 100644 --- a/tests/test.py +++ b/tests/test.py @@ -80,6 +80,18 @@ class TestMarkupParserBasic (unittest.TestCase): def test_itbold3(self): self.assertTrue(self.__test('itbold3')) pass + + def test_nowiki(self): + self.assertTrue(self.__test('nowiki')) + pass + + def test_nowiki_tag(self): + self.assertTrue(self.__test('nowiki-tag')) + pass + + def test_nowiki_ind(self): + self.assertTrue(self.__test('nowiki-ind')) + pass # def test_door(self): # self.assertTrue(self.__test('door')) |