Permalink
Browse files

Make <body> tag generation optional (closes #31).

Parsing with the 'wikitext' parser will parse and render as expected and
do nothing more. This is useful for the inclusion of the article content in
a larger HTML page.

Parsing with the 'body' parser will also add the <body>...</body> tags
and the interwiki links and category links. This is useful to mimic the
behavior of MediaWiki's parser when rendering a whole article as a web
page.
  • Loading branch information...
1 parent cbf369c commit a6f9e78c91790eb9f719d8b3c9616a5dd303abe7 @peter17 peter17 committed Aug 2, 2011
Showing with 117 additions and 118 deletions.
  1. +3 −0 html.py
  2. +3 −2 mediawiki.pijnu
  3. +12 −9 raw.py
  4. +82 −95 tests/test_html_postprocessor.py
  5. +11 −8 text.py
  6. +6 −4 wikitextParser.py
View
@@ -81,6 +81,9 @@ def render_paragraph(node):
if value != '':
node.value = '<p>' + value + '</p>\n'
+ def render_wikitext(node):
+ node.value = content(node)
+
def render_body(node):
metadata = ''
if category_links != []:
View
@@ -226,5 +226,6 @@ def replace_by_space(node):
# Top pattern
- wikitext : list / horizontal_rule / preformatted_group / title / table / EOL / paragraphs
- body : optional_comment (wikitext/invalid_line)+ : liftValue render_body
+ valid_syntax : list/horizontal_rule/preformatted_group/title/table/EOL/paragraphs
+ wikitext : optional_comment (valid_syntax/invalid_line)+ : liftValue render_wikitext
+ body : wikitext{1} : liftValue render_body
View
21 raw.py
@@ -19,35 +19,38 @@ def render_title5(node):
def render_title6(node):
pass
-
+
def render_raw_text(node):
pass
-
+
def render_paragraph(node):
pass
-
+
+ def render_wikitext(node):
+ pass
+
def render_body(node):
pass
-
+
def render_entity(node):
value = '%s' % node.leaf()
if value in html_entities:
node.value = '%s' % unichr(html_entities[value])
else:
node.value = '&%s;' % value
-
+
def render_lt(node):
pass
-
+
def render_gt(node):
pass
-
+
def render_tag_open(node):
pass
-
+
def render_tag_close(node):
pass
-
+
def render_tag_autoclose(node):
pass
Oops, something went wrong.

0 comments on commit a6f9e78

Please sign in to comment.