',
@@ -79,7 +80,7 @@ Ox.parseHTML = (function() {
tags = tags || defaultTags;
// html = Ox.clean(html); fixme: can this be a parameter?
if (tags.indexOf('[]') > -1) {
- html = html.replace(/\[(https?:\/\/.+?) (.+?)\]/gi, '
$2');
+ html = html.replace(/\[((https?:\/\/|\/).+?) (.+?)\]/gi, '
$3');
tags = tags.filter(function(tag) {
return tag != '[]';
});
@@ -94,8 +95,9 @@ Ox.parseHTML = (function() {
});
});
html = Ox.encodeHTML(html);
- html = Ox.parseURLs(html);
- html = Ox.parseEmailAddresses(html);
+ //fixme: both fail if urls/emails are already links
+ //html = Ox.parseURLs(html);
+ //html = Ox.parseEmailAddresses(html);
matches.forEach(function(match, i) {
html = html.replace(new RegExp(tab + i + tab, 'gi'), match);
});
@@ -146,9 +148,17 @@ Ox.parseURL = (function() {
/*@
Ox.parseURLs
Takes HTML and turns URLs into links
+ > Ox.parseURLs('http://foo.com, bar')
+ 'http://foo.com, bar'
+ > Ox.parseURLs('http://foo.com/foobar?foo, bar')
+ 'http://foo.com/foobar?foo, bar'
+ > Ox.parseURLs('www.foo.com, bar')
+ 'www.foo.com, bar'
+ > Ox.parseURLs('http://foo.com etc')
+ 'http://foo.com etc'
@*/
-// fixme: no tests
// fixme: shouldn't this be formatURLs?
+// fixme: fails for urls inside links
Ox.parseURLs = function(html) {
return html.replace(
/\b((https?:\/\/|www\.).+?)([\.,:;!\?\)\]]*?(\s|$))/gi,