summaryrefslogtreecommitdiff
path: root/trac2md.py
diff options
context:
space:
mode:
Diffstat (limited to 'trac2md.py')
-rwxr-xr-xtrac2md.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/trac2md.py b/trac2md.py
index dd519eb..a8a632b 100755
--- a/trac2md.py
+++ b/trac2md.py
@@ -23,6 +23,8 @@ wikilink_3_pattern = re.compile(r"\[\[(?:wiki:)?([^][]+)\]\]|\[wiki:([^][]+)\]")
strikethrough_pattern = re.compile(r"~~(.*)~~")
camelcase_pattern = re.compile(r"!((?:\w|[#])+)")
+span_pattern = re.compile(r"\[\[span\((?:[^][]*,)*\[([^(), ]+)([^(),]+)\]\)\]\]")
+
wikiheading_patterns = tuple(
(level, re.compile("^{} (.*)[ \t]*=*$".format("=" * level)))
for level in range(1, 7))
@@ -87,6 +89,7 @@ def convert_strike(line):
pass
return line
+
def convert_image(line, slug):
image_result = image_pattern.search(line)
if image_result:
@@ -102,12 +105,14 @@ def convert_image(line, slug):
pass
return line
+
def convert_linebreak(line):
# Markdown spec says linebreak is <SPACE><SPACE><RETURN>, who am I to argue?
if line.endswith("\\\\"):
line = line[:-2] + " "
return line
+
def WikiToMD(content, slug):
# Line breaks in Markdown must be at end of line, so add newlines as needed
@@ -190,7 +195,10 @@ def WikiToMD(content, slug):
prev_indent = 0
# Convert CamelCase
- line = camelcase_pattern.sub("\\1", line)
+ line = camelcase_pattern.sub(r"\1", line)
+
+ # Convert (limited subset of) spans
+ line = span_pattern.sub(r"[[\1|\2]]", line)
# Convert headers
line = convert_headers(line)