- allow links to local images
- allow wiki links to local urls - disable automatic url / email linking since its broken right now
This commit is contained in:
parent
21854f653e
commit
a976b674f4
1 changed files with 15 additions and 5 deletions
|
@ -5,6 +5,7 @@ Ox.parseEmailAddresses <f> Takes HTML and turns e-mail addresses into links
|
|||
@*/
|
||||
// fixme: no tests
|
||||
// fixme: shouldn't this be formatEmailAddresses?
|
||||
// fixme: fails for linked emails
|
||||
Ox.parseEmailAddresses = function(html) {
|
||||
return html.replace(
|
||||
/\b([0-9A-Z\.\+\-_]+@(?:[0-9A-Z\-]+\.)+[A-Z]{2,6})\b/gi,
|
||||
|
@ -61,7 +62,7 @@ Ox.parseHTML = (function() {
|
|||
'<\/a>': '</a>'
|
||||
},
|
||||
img: {
|
||||
'<img [^<>]*?src="(https?:\/\/.+?)".*?>': '<img src="{1}">'
|
||||
'<img [^<>]*?src="((https?:\/\/|\/).+?)".*?>': '<img src="{1}">'
|
||||
},
|
||||
rtl: {
|
||||
'<rtl>': '<div style="direction: rtl">',
|
||||
|
@ -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, '<a href="$1">$2</a>');
|
||||
html = html.replace(/\[((https?:\/\/|\/).+?) (.+?)\]/gi, '<a href="$1">$3</a>');
|
||||
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 <f> Takes HTML and turns URLs into links
|
||||
> Ox.parseURLs('http://foo.com, bar')
|
||||
'<a href="http://foo.com">http://foo.com</a>, bar'
|
||||
> Ox.parseURLs('http://foo.com/foobar?foo, bar')
|
||||
'<a href="http://foo.com/foobar?foo">http://foo.com/foobar?foo</a>, bar'
|
||||
> Ox.parseURLs('www.foo.com, bar')
|
||||
'<a href="http://www.foo.com">www.foo.com</a>, bar'
|
||||
> Ox.parseURLs('<a href="http://foo.com">http://foo.com</a> etc')
|
||||
'<a href="http://foo.com">http://foo.com</a> 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,
|
||||
|
|
Loading…
Reference in a new issue