Ox.sanitizeHTML: add replaceTags option
This commit is contained in:
parent
092f27ca19
commit
3cdaebadee
1 changed files with 4 additions and 3 deletions
|
@ -40,7 +40,7 @@
|
|||
img: [
|
||||
[
|
||||
/<img [^<>]*?src="((\/|https?:\/\/).+?)".*?>/gi,
|
||||
'<img src="$1">'
|
||||
'<img src="{1}">'
|
||||
]
|
||||
],
|
||||
rtl: [
|
||||
|
@ -499,9 +499,10 @@
|
|||
> Ox.sanitizeHTML('<http://foo.com>')
|
||||
'<<a href="http://foo.com">http://foo.com</a>>'
|
||||
@*/
|
||||
Ox.sanitizeHTML = function(html, tags) {
|
||||
Ox.sanitizeHTML = function(html, tags, replaceTags) {
|
||||
var matches = [];
|
||||
tags = tags || defaultTags;
|
||||
replaceTags = replaceTags || {};
|
||||
// html = Ox.clean(html); fixme: can this be a parameter?
|
||||
if (tags.indexOf('[]') > -1) {
|
||||
html = html.replace(
|
||||
|
@ -513,7 +514,7 @@
|
|||
});
|
||||
}
|
||||
tags.forEach(function(tag) {
|
||||
var array = replace[tag] || replace['*'](tag);
|
||||
var array = replaceTags[tag] || replace[tag] || replace['*'](tag);
|
||||
Ox.forEach(array, function(value) {
|
||||
html = html.replace(value[0], function() {
|
||||
matches.push(Ox.formatString(value[1], arguments));
|
||||
|
|
Loading…
Reference in a new issue