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

Commit b9b1a22

Browse files
committed
Fix a few parsing bugs
1 parent fd0e858 commit b9b1a22

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

wikiconvert.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ def convert_file(proj_id, src_path, dst_dir):
3838
for i, line in enumerate(lines):
3939
if line.startswith("#"):
4040
meta_lines.append(line)
41-
else:
42-
assert not line.strip(), "line isn't empty in file %s %r" % (src_path, line)
43-
# TODO is it actually mandatory that a blank line separate meta text from body text?
44-
body_lines = lines[i+1:]
41+
elif line.strip():
42+
body_lines = lines[i:]
4543
break
4644
meta = {}
4745
for line in meta_lines:
@@ -58,6 +56,7 @@ def convert_file(proj_id, src_path, dst_dir):
5856
text = re.compile(r'^}}}+ *(\n|$)', re.M).sub(r"```\n", text)
5957

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

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

133132
def _indent(text):
134-
return ' ' + '\n '.join(text.splitlines(False))
133+
return '\n ' + '\n '.join(text.splitlines(False))
135134

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

142140

0 commit comments

Comments
 (0)