rename Ox.highlightHTML to Ox.highlight

This commit is contained in:
rolux 2012-06-03 10:40:46 +02:00
parent ce3c5a4a03
commit 90147a69fb

View file

@ -226,32 +226,32 @@
};
/*@
Ox.highlightHTML <f> Highlight matches in string
Ox.highlight <f> Highlight matches in string
(string, query, classname[, isHTML]) -> Output string
string <s> Input string
query <r|s> Case-insentitive query string, or regular expression
classname <s> Class name for matches
isHTML <b|false> If true, the input string is treated as HTML
> Ox.highlightHTML('<name>', 'name', 'c')
> Ox.highlight('<name>', 'name', 'c')
'&lt;<span class="c">name</span>&gt;'
> Ox.highlightHTML('<span class="name">name</span>', 'name', 'c', true)
> Ox.highlight('<span class="name">name</span>', 'name', 'c', true)
'<span class="name"><span class="c">name</span></span>'
> Ox.highlightHTML('amp &amp; amp', 'amp', 'c', true)
> Ox.highlight('amp &amp; amp', 'amp', 'c', true)
'<span class="c">amp</span> &amp; <span class="c">amp</span>'
> Ox.highlightHTML('amp &amp; amp', 'amp & amp', 'c', true)
> Ox.highlight('amp &amp; amp', 'amp & amp', 'c', true)
'<span class="c">amp &amp; amp</span>'
> Ox.highlightHTML('<b>&lt;b&gt;</b>', '<b>', 'c', true)
> Ox.highlight('<b>&lt;b&gt;</b>', '<b>', 'c', true)
'<span class="c"><b>&lt;b&gt;</b></span>'
> Ox.highlightHTML('<b>&lt;b&gt;</b>', '&lt;b&gt;', 'c', true)
> Ox.highlight('<b>&lt;b&gt;</b>', '&lt;b&gt;', 'c', true)
'<b>&lt;b&gt;</b>'
> Ox.highlightHTML('foo<b>bar</b>baz', 'foobar', 'c', true)
> Ox.highlight('foo<b>bar</b>baz', 'foobar', 'c', true)
'<span class="c">foo<b>bar</b></span>baz'
> Ox.highlightHTML('foo<p>bar</p>baz', 'foobar', 'c', true)
> Ox.highlight('foo<p>bar</p>baz', 'foobar', 'c', true)
'foo<p>bar</p>baz'
> Ox.highlightHTML('foo <br/>bar baz', 'foo bar', 'c', true)
> Ox.highlight('foo <br/>bar baz', 'foo bar', 'c', true)
'<span class="c">foo <br>bar</span> baz'
@*/
Ox.highlightHTML = function(string, query, classname, isHTML) {
Ox.highlight = function(string, query, classname, isHTML) {
var cursor = 0,
entities = [],
matches = [],
@ -322,7 +322,6 @@
span.join(match.value)
);
});
} else {
string = string.replace(re, function(value) {
return span.join(value);