diff options
author | Rob Austein <sra@hactrn.net> | 2021-02-14 02:19:20 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2021-02-14 02:19:20 +0000 |
commit | 8e59cfff8f67a0c22d11f988afb3d95fa8530174 (patch) | |
tree | 704af0ed268d2dfe011b759f13983ece6bd71c72 /tools | |
parent | e6fc8bed7e3a5e80882781359543c99d7de018fe (diff) |
linebreaks
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/trac2md.py | 12 |
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 |