Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Fix a few parsing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lipnitsk committed Dec 15, 2014
1 parent fd0e858 commit b9b1a22
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions wikiconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ def convert_file(proj_id, src_path, dst_dir):
for i, line in enumerate(lines):
if line.startswith("#"):
meta_lines.append(line)
else:
assert not line.strip(), "line isn't empty in file %s %r" % (src_path, line)
# TODO is it actually mandatory that a blank line separate meta text from body text?
body_lines = lines[i+1:]
elif line.strip():
body_lines = lines[i:]
break
meta = {}
for line in meta_lines:
Expand All @@ -58,6 +56,7 @@ def convert_file(proj_id, src_path, dst_dir):
text = re.compile(r'^}}}+ *(\n|$)', re.M).sub(r"```\n", text)

# TODO: Add support for `backtick` code quotes
text = re.sub(r'{{{(.*?)}}}', r'`\1`', text)

# Headings.
text = re.compile(r'^===(.*?)===\s*$', re.M).sub(lambda m: "### %s\n"%m.group(1).strip(), text)
Expand Down Expand Up @@ -131,12 +130,11 @@ def sub_link(m):
#---- internal support stuff

def _indent(text):
return ' ' + '\n '.join(text.splitlines(False))
return '\n ' + '\n '.join(text.splitlines(False))

def _gh_page_name_from_gc_page_name(gc):
"""Github (gh) Wiki page name from Google Code (gc) Wiki page name."""
# FIXME: fails on all uppercase / all lowercase names (e.g. FAQ)
gh = re.sub(r'([A-Z][a-z]+)', r'-\1', gc)[1:]
gh = re.sub(r'([A-Za-z]+)_?', r'-\1', gc)[1:]
return gh


Expand Down

0 comments on commit b9b1a22

Please sign in to comment.