-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("highlight", {
exports: ["Highlight", "Highlights", "highlight"],
require: ["services", "util"]
-}, this);
+});
-this.lazyRequire("styles", ["Styles", "styles"]);
+lazyRequire("styles", ["Styles", "styles"]);
+lazyRequire("template", ["template"]);
var Highlight = Struct("class", "selector", "sites",
"defaultExtends", "defaultValue",
* @param {string} group
*/
highlightNode: function highlightNode(node, group, applyBindings) {
- node.setAttributeNS(NS.uri, "highlight", group);
+ node.setAttributeNS(NS, "highlight", group);
let groups = group.split(" ");
for each (let group in groups)
(self.highlight[hl] && self.highlight[hl].class != class_
? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")),
- groupRegexp: util.regexp(<![CDATA[
+ groupRegexp: util.regexp(literal(/*
^
(\s* (?:\S|\s\S)+ \s+)
\{ ([^}]*) \}
\s*
$
- ]]>, "gmx"),
- sheetRegexp: util.regexp(<![CDATA[
+ */), "gmx"),
+ sheetRegexp: util.regexp(literal(/*
^\s*
!? \*?
(?P<group> (?:[^;\s]|\s[^;\s])+ )
(?:; (?P<extends> (?:[^;\s]|\s[^;\s])+ )? )?
\s* (?P<css> .*)
$
- ]]>, "x"),
+ */), "x"),
+ // </css>
/**
* Bulk loads new CSS rules, in the format of,
commands.add(["hi[ghlight]"],
"Set the style of certain display elements",
function (args) {
- let style = <![CDATA[
+ let style = literal(/*
;
display: inline-block !important;
position: static !important;
width: 3em !important; min-width: 3em !important; max-width: 3em !important;
height: 1em !important; min-height: 1em !important; max-height: 1em !important;
overflow: hidden !important;
- ]]>;
+ */);
let clear = args[0] == "clear";
if (clear)
args.shift();
["padding: 0 1em 0 0; vertical-align: top; max-width: 16em; overflow: hidden;",
"text-align: center"],
([h.class,
- <span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>,
- template.map(h.extends, function (s) template.highlight(s), <>,</>),
+ ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"],
+ template.map(h.extends, function (s) template.highlight(s), ","),
template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
- function (match) <span highlight={match[0] == "/" ? "Comment" : "Key"}>{match}</span>)
+ function (match) ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])
]
for (h in highlight)
if (!key || h.class.indexOf(key) > -1))));