1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-25 21:15:46 +01:00

Add cheap CSS highlighting which is unfortunately far to slow to make any use of.

This commit is contained in:
Kris Maglione
2011-01-13 14:20:32 -05:00
parent 671077f1e7
commit 203730ae62
3 changed files with 89 additions and 8 deletions

View File

@@ -161,14 +161,15 @@ var Template = Module("Template", {
highlightRegexp: function highlightRegexp(str, re, highlight) {
return this.highlightSubstrings(str, (function () {
re.lastIndex = 0;
let res;
while ((res = re.exec(str)) && res[0].length)
yield [res.index, res[0].length, res];
yield [res.index, res[0].length, res.wholeMatch ? [res] : res];
})(), highlight || template.filter);
},
highlightSubstrings: function highlightSubstrings(str, iter, highlight) {
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
XML.ignoreWhitespace = XML.prettyPrinting = false;
if (typeof str == "xml")
return str;
if (str == "")