diff options
author | Rob Austein <sra@hactrn.net> | 2021-02-15 22:30:14 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2021-02-15 22:30:14 +0000 |
commit | 7acac1b6d1d8fbbe4b3c407be891f8bf65120c93 (patch) | |
tree | 97d10fb0be06c5a32b933b8785ea98524f30d598 /trac2md.py | |
parent | 18fb1695b84248fc75ceb3569ff03cbeca51a620 (diff) |
Handle bare URLs
Diffstat (limited to 'trac2md.py')
-rwxr-xr-x | trac2md.py | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -57,7 +57,7 @@ def convert_traclink_to_creolelink(line): text = m.group(1).strip() if " " in text: line = line.replace(m.group(0), "[[{0[0]}|{0[1]}]]".format(text.split(" ", 1))) - elif any(text.startswith(scheme) for scheme in ("wiki:", "attachment:")) or camelcase_pattern.match(text): + elif any(text.startswith(scheme) for scheme in ("http:", "https:", "wiki:", "attachment:")) or camelcase_pattern.match(text): line = line.replace(m.group(0), "[[{}]]".format(text)) return line @@ -71,22 +71,15 @@ def convert_wikilinks(line, slug): link = link[1:-1] if any(text.startswith(q) and text.endswith(q) for q in ('"', "'")): text = text[1:-1] - if scheme == "attachment:": + if text == link and link.startswith("http") and "://" in link: + mdlink = "<{}>".format(link) + elif scheme == "attachment:": mdlink = "[{}]({{attach}}{}/{})".format(text, slug, link) elif scheme == "wiki:" or (scheme is None and camelcase_pattern.match(link)): mdlink = "[{}]({}.md)".format(text, link) else: mdlink = "[{}]({})".format(text, link) - # - #whine = "/user/sra/build-tools/https-sync-repos" in line - whine = False - if whine: - print("Old:", line) line = line.replace(m.group(0), mdlink) - if whine: - print("New:", line) - whine = False - # return line |