updates for html parsing, request handling, and editable elements
This commit is contained in:
parent
a949ad2cf4
commit
62f8a907ea
6 changed files with 153 additions and 69 deletions
|
|
@ -37,15 +37,22 @@ Ox.parseHTML <f> Takes HTML from an untrusted source and returns something sane
|
|||
|
||||
Ox.parseHTML = (function() {
|
||||
var defaultTags = [
|
||||
'a', 'b', 'blockquote', 'br', 'cite', 'code',
|
||||
'del', 'em', 'i', 'img', 'ins',
|
||||
'li', 'ol', 'p', 'q', 'rtl',
|
||||
's', 'strong', 'sub', 'sup',
|
||||
'table', 'tbody', 'td', 'th', 'tr', 'ul', '[]'
|
||||
// inline formatting
|
||||
'b', 'code', 'i', 'q', 's', 'sub', 'sup', 'u',
|
||||
// block
|
||||
'blockquote', 'h1', 'p', 'pre',
|
||||
// lists
|
||||
'li', 'ol', 'ul',
|
||||
// tables
|
||||
'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr',
|
||||
// other
|
||||
'a', 'br', 'img',
|
||||
// special
|
||||
'rtl', '[]'
|
||||
],
|
||||
parse = {
|
||||
a: {
|
||||
'<a [^<>]*?href="(https?:\/\/.+?)".*?>': '<a href="{1}" title="{1}">',
|
||||
'<a [^<>]*?href="((https?:\/\/|\/).+?)".*?>': '<a href="{1}" title="{1}">',
|
||||
'<\/a>': '</a>'
|
||||
},
|
||||
img: {
|
||||
|
|
@ -90,7 +97,7 @@ Ox.parseHTML = (function() {
|
|||
html = html.replace(new RegExp(tab + i + tab, 'gi'), match);
|
||||
});
|
||||
//html = html.replace(/\n/g, '<br/>\n');
|
||||
html = html.replace(/\n/g, '<br/>');
|
||||
html = html.replace(/\n\n/g, '<br/><br/>');
|
||||
// close extra opening (and remove extra closing) tags
|
||||
// note: this converts '"' to '"'
|
||||
return Ox.element('<div>').html(html).html();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue