Permalink
Browse files

Merge erikrose / mediawiki-parser

  • Loading branch information...
2 parents 8afbab2 + 8950627 commit a30c1a07bb08ccb7eeb672f609f17010ce7c773e @peter17 peter17 committed Apr 16, 2012
Showing with 66 additions and 6 deletions.
  1. +10 −0 README.rst
  2. +50 −0 tests/test_text_postprocessor.py
  3. +6 −6 text.py
View
@@ -27,7 +27,17 @@ and the wikitext will be rendered as HTML in the article.htm file.
Other ways might be implemented in the future.
+Unit tests
+----------
+Install nose and run:
+
+::
+
+ cd /PATH/TO/mediawiki-parser/
+ ln -s ../mediawiki-parser/ mediawiki_parser
+ export PYTHONPATH=/PATH/TO/mediawiki-parser/:/PATH/TO/pijnu/
+ nosetests tests
How to use in a program
=======================
@@ -4,16 +4,66 @@
class TextBackendTests(PostprocessorTestCase):
+ def test_simple_title(self):
+ source = '= A title =\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+
def test_simple_title2(self):
source = '== A title ==\n'
result = ' A title \n'
self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+ def test_simple_title3(self):
+ source = '=== A title ===\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+
+ def test_simple_title4(self):
+ source = '==== A title ====\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+
+ def test_simple_title5(self):
+ source = '==== A title ====\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+
def test_simple_title6(self):
source = '====== Test! ======\n'
result = ' Test! \n'
self.parsed_equal_string(source, result, 'wikitext', {}, 'text')
+ def test_simple_title_without_method(self):
+ source = '= A title =\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
+ def test_simple_title2_without_method(self):
+ source = '== A title ==\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
+ def test_simple_title3_without_method(self):
+ source = '=== A title ===\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
+ def test_simple_title4_without_method(self):
+ source = '==== A title ====\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
+ def test_simple_title5_without_method(self):
+ source = '==== A title ====\n'
+ result = ' A title \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
+ def test_simple_title6_without_method(self):
+ source = '====== Test! ======\n'
+ result = ' Test! \n'
+ self.parsed_equal_string(source, result, None, {}, 'text')
+
def test_simple_allowed_open_tag(self):
source = 'a<p>test'
result = 'a\ntest'
View
12 text.py
@@ -13,22 +13,22 @@ def render_tag_br(attributes):
'br': render_tag_br}
def render_title1(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_title2(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_title3(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_title4(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_title5(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_title6(node):
- node.value += '\n'
+ node.value = '%s\n' % node.leaf()
def render_raw_text(node):
pass

0 comments on commit a30c1a0

Please sign in to comment.