Browse Source

Fix a couple bugs.

tags/v0.2
Ben Kurtovic 11 years ago
parent
commit
35acc1b812
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      mwparserfromhell/wikicode.py
  2. +2
    -2
      tests/test_wikicode.py

+ 1
- 1
mwparserfromhell/wikicode.py View File

@@ -370,7 +370,7 @@ class Wikicode(StringMixIn):
if self.nodes[i] in headings: if self.nodes[i] in headings:
this = self.nodes[i].level this = self.nodes[i].level
for (level, start) in buffers: for (level, start) in buffers:
if not flat or this <= level:
if this <= level:
buffers.remove((level, start)) buffers.remove((level, start))
sections.append(Wikicode(self.nodes[start:i])) sections.append(Wikicode(self.nodes[start:i]))
buffers.append((this, i)) buffers.append((this, i))


+ 2
- 2
tests/test_wikicode.py View File

@@ -305,8 +305,8 @@ Even more text.
An invalid section!""" An invalid section!"""


self.assertEqual([], parse(page1).get_sections()) self.assertEqual([], parse(page1).get_sections())
self.assertEqual(["==Heading=="], parse(page2).get_sections())
self.assertEqual(["===Heading===\nFoo bar baz\n", "====Gnidaeh====\n"], parse(page2).get_sections())
self.assertEqual(["", "==Heading=="], parse(page2).get_sections())
self.assertEqual(["", "===Heading===\nFoo bar baz\n====Gnidaeh====\n", "====Gnidaeh====\n"], parse(page3).get_sections())


def test_strip_code(self): def test_strip_code(self):
"""test Wikicode.strip_code()""" """test Wikicode.strip_code()"""


Loading…
Cancel
Save