comparison tools/mdx_urlize.py @ 658:2adf01661ac5

Need to update the Markdown urlize extension too. For reference, here is where I got it: https://github.com/r0wb0t/markdown-urlize
author Brian Neal <bgneal@gmail.com>
date Sat, 11 May 2013 16:21:55 -0500
parents f54bf3b3bece
children
comparison
equal deleted inserted replaced
657:6467eabe74d4 658:2adf01661ac5
1 """ 1 """A more liberal autolinker
2 Taken from: https://github.com/r0wb0t/markdown-urlize
3
4 A more liberal autolinker
5 2
6 Inspired by Django's urlize function. 3 Inspired by Django's urlize function.
7 4
8 Positive examples: 5 Positive examples:
9 6
62 if '@' in url and not '/' in url: 59 if '@' in url and not '/' in url:
63 url = 'mailto:' + url 60 url = 'mailto:' + url
64 else: 61 else:
65 url = 'http://' + url 62 url = 'http://' + url
66 63
67 el = markdown.etree.Element("a") 64 el = markdown.util.etree.Element("a")
68 el.set('href', url) 65 el.set('href', url)
69 el.text = markdown.AtomicString(text) 66 el.text = markdown.util.AtomicString(text)
70 return el 67 return el
71 68
72 class UrlizeExtension(markdown.Extension): 69 class UrlizeExtension(markdown.Extension):
73 """ Urlize Extension for Python-Markdown. """ 70 """ Urlize Extension for Python-Markdown. """
74 71