From 8e59cfff8f67a0c22d11f988afb3d95fa8530174 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 14 Feb 2021 02:19:20 +0000 Subject: linebreaks --- tools/trac2md.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tools') 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 , 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 -- cgit v1.2.3