From 411c5a695cfb64bc04ec34f4739cc705f436da21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 6 Feb 2011 23:19:21 +0200 Subject: [PATCH] some formatting rules from the parl script --- moin2doku.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/moin2doku.py b/moin2doku.py index 7200d8c..eb69df1 100755 --- a/moin2doku.py +++ b/moin2doku.py @@ -105,7 +105,7 @@ def copy_attachments(page_dir, attachment_dir): cmd_string = 'cp -p "' + dir +'/' + attachment + '" "' + attachment_dir + attachment.lower() + '"' os.system(cmd_string) -def convert_markup(page, filename): +def convert_markup(content, filename): """ convert page markup """ @@ -113,12 +113,25 @@ def convert_markup(page, filename): for i in range(0, len(filename) - 1): namespace += filename[i] + ':' + # http://www.pld-linux.org/SyntaxReference regexp = ( ('\[\[TableOfContents.*\]\]', ''), # remove ('\[\[BR\]\]$', ''), # newline at end of line - remove ('\[\[BR\]\]', '\n'), # newline ('#pragma section-numbers off', ''), # remove - ('^##.*?\\n', ''), # remove + ('^##.*?\\n', ''), # comments: remove + ('^#(pragma|format|redirect|refresh|language)(.*)', ''), # remove all + ('^#deprecated(.*)\n', 'This page is deprecated\n'), # deprecated + + # Other elements + # break + ('(<
>)|(\[\[BR]])', '\\\\ '), + + # horizontal line + ('^\s*-{4,}\s*$', '----\n'), + # Macros and another foolish - simply remove + # macros + ('<<.+?>>', ''), # ('\["', '[['), # internal link open # ('"\]', ']]'), # internal link close @@ -160,12 +173,12 @@ def convert_markup(page, filename): ('attachment:(.*)','{{'+namespace+'\\1|}}') ) - for i in range(len(page)): - line = page[i] + for i in range(len(content)): + line = content[i] for item in regexp: line = re.sub(item[0], item[1], line) - page[i] = line - return page + content[i] = line + return content def print_help(): print "Usage: moinconv.py "