Handle more softly words with :// that don't match known link types.

This commit is contained in:
Sergio Martínez Portela 2022-11-04 00:33:16 +01:00
parent 76531e3cfc
commit 08d35fc0b5

View File

@ -453,13 +453,15 @@ def render_text_tokens(tokens, acc, headline, graph):
for line in lines: for line in lines:
line_chunks = [] line_chunks = []
for word in TEXT_OR_LINK_RE.findall(line): 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://') if not (word.startswith('http://')
or word.startswith('https://') or word.startswith('https://')
or word.startswith('ftp://') or word.startswith('ftp://')
or word.startswith('ftps://') or word.startswith('ftps://')
): ):
raise Exception('Is this a link? {} (on {})\nLine: {}\nChunks: {}'.format(word, headline.doc.path, line, chunks)) 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>' line_chunks.append('<a href="{url}" class="external">{description}</a>'
.format(url=word, .format(url=word,
description=html.escape(word))) description=html.escape(word)))