decodeAll
relies on
Ox.normalizeHTML
, which uses the DOM and may transform
the string
> Ox.decodeHTMLEntities('<'&">')
'<\'&">'
> Ox.decodeHTMLEntities('<'&">')
'<\'&">'
> Ox.decodeHTMLEntities('äbçdê')
'äbçdê'
> Ox.decodeHTMLEntities('äbçdê')
'äbçdê'
> Ox.decodeHTMLEntities('äbçdê', true)
'äbçdê'
> Ox.decodeHTMLEntities('β')
'β'
> Ox.decodeHTMLEntities('β', true)
'β'
> Ox.decodeHTMLEntities('<b>')
''
@*/
Ox.decodeHTMLEntities = function(string, decodeAll) {
return decodeAll
? Ox.decodeHTMLEntities(Ox.normalizeHTML(string))
: String(string)
.replace(replace.namedEntity[0], replace.namedEntity[1])
.replace(replace.numericEntity[0], replace.numericEntity[1]);
};
/*@
Ox.highlightHTML bar
baz', 'foobar', 'c', true) 'foobar
baz' > Ox.highlightHTML('foofoo
\`\`\`code\`\`\` -> foo
[example](http://example.com "example.com") -> example
> Ox.parseMarkdown('*foo* **bar** `baz` ``back`tick``')
'foo bar baz
back`tick
'
> Ox.parseMarkdown('[example](http://example.com "example.com")')
'example'
> Ox.parseMarkdown('[example](http://example.com?foo=bar&bar=baz)')
'example'
*/
Ox.parseMarkdown = function(string) {
// see https://github.com/coreyti/showdown/blob/master/src/showdown.js
return string.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
.replace(/\n\n/g, ''
+ Ox.encodeHTMLEntities(b) + '\n
';
}
)
.replace(
/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
function(match, a, b, c, d) {
return a + ''
+ Ox.encodeHTMLEntities(c.trim()) + '
';
}
)
.replace(
/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,
function(match, a, b, c, d, e, f, g) {
return '' + b + '';
}
);
};
/*@
Ox.sanitizeHTML