aboutsummaryrefslogtreecommitdiff
path: root/tools/trac2md.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/trac2md.py')
-rwxr-xr-xtools/trac2md.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/trac2md.py b/tools/trac2md.py
index 214471f..c022899 100755
--- a/tools/trac2md.py
+++ b/tools/trac2md.py
@@ -117,10 +117,19 @@ def convert_image(line):
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):
''' Convert wiki/RST format to Markdown. Code blocks, bold/italics,
wiki links, lists, striked text, and headers. '''
+ # Line breaks in Markdown must be at end of line, so add newlines as needed
+ content = content.replace("[[br]]", "\\\\").replace("[[BR]]", "\\\\").replace("\\\\", "\\\\\n")
+
code_block = False
in_list = False
in_table = False
@@ -212,6 +221,9 @@ def WikiToMD(content):
# Convert images
line = convert_image(line)
+ # Convert line breaks
+ line = convert_linebreak(line)
+
# Convert bold and italic text (do this last)
line = line.replace("'''", "**") # Convert bold text
line = line.replace("''", "*") # Convert italic text