diff --git a/_scripts/helpers.py b/_scripts/helpers.py index 4c1edd9865..4155f6ed0f 100644 --- a/_scripts/helpers.py +++ b/_scripts/helpers.py @@ -110,7 +110,7 @@ def cleanse(txt): def datasheet_link(text): - links = ['http', 'www', 'ftp'] + links = ['https:', 'http:', 'www.', 'ftp:'] if not text: text = '' @@ -123,24 +123,21 @@ def datasheet_link(text): el = element - # Strip quote characters - start = ['"', "'", "[", "(", "{", ":"] - end = ['"', "'", "]", ")", "}", ".", ","] - - for s in start: - if el.startswith(s): - el = el[1:] - - for e in end: - if el.endswith(e): - el = el[:-1] - + # Strip illegal characters + quotes = "\"'[]{}():.,; *" + + # Remove from start + while any([el.startswith(q) for q in quotes]): + el = el[1:] + + # Remove from end + while any([el.endswith(q) for q in quotes]): + el = el[:-1] + + # Links must be remote if any([el.lower().startswith(i) for i in links]): link = True - elif el.endswith('.pdf') or '.htm' in el: - link = True - if link: element = '{text}'.format(link=el, text=element)