chrisdrackett/python-textile — Issue #8: auto_link=True breaks link syntax
Author: hupf
Created: 2012-02-16 16:25:13+00:00
State: open

Given you have the following textile text:

"Superhuman":https://en.wikipedia.org/wiki/Superhuman
https://en.wikipedia.org/wiki/Superhuman
www.wikipedia.org
foo en.wikipedia.org/wiki/Superhuman bar

Rendered with _auto_link=True_, the output is:

```html

“Superhuman”:https://en.wikipedia.org/wiki/Superhuman

https://en.wikipedia.org/wiki/Superhuman

www.wikipedia.org

foo en.wikipedia.org/wiki/Superhuman bar

```

Obviously _autoLink()_ breaks the textile link syntax (_"a link":http://example.org/_). I'd rather expect the following output, with both working:

```html

Superhuman

https://en.wikipedia.org/wiki/Superhuman

www.wikipedia.org

foo en.wikipedia.org/wiki/Superhuman bar

```

It probably has something to do with the leading _\b_ in the _autoLink()_ pattern which not only matches whitespace or the beginning of the text:

```python
pattern = re.compile(r"""\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))""", re.U | re.I)
return pattern.sub(r'"\1":\1', text)
```