Handle more softly words with :// that don't match known link types.
This commit is contained in:
parent
76531e3cfc
commit
08d35fc0b5
@ -453,16 +453,18 @@ def render_text_tokens(tokens, acc, headline, graph):
|
||||
for line in lines:
|
||||
line_chunks = []
|
||||
for word in TEXT_OR_LINK_RE.findall(line):
|
||||
if ':/' in word and not (word.startswith('org-protocol://')):
|
||||
if '://' in word and not (word.startswith('org-protocol://')):
|
||||
if not (word.startswith('http://')
|
||||
or word.startswith('https://')
|
||||
or word.startswith('ftp://')
|
||||
or word.startswith('ftps://')
|
||||
):
|
||||
raise Exception('Is this a link? {} (on {})\nLine: {}\nChunks: {}'.format(word, headline.doc.path, line, chunks))
|
||||
line_chunks.append('<a href="{url}" class="external">{description}</a>'
|
||||
.format(url=word,
|
||||
description=html.escape(word)))
|
||||
logging.warning('Is this a link? {} (on {})\nLine: {}\nChunks: {}'.format(word, headline.doc.path, line, line_chunks))
|
||||
line_chunks.append(html.escape(word))
|
||||
else:
|
||||
line_chunks.append('<a href="{url}" class="external">{description}</a>'
|
||||
.format(url=word,
|
||||
description=html.escape(word)))
|
||||
else:
|
||||
line_chunks.append(html.escape(word))
|
||||
contents.append(''.join(line_chunks))
|
||||
|
Loading…
Reference in New Issue
Block a user