diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-03-07 22:33:53 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-03-07 22:33:53 -0500 |
commit | 49fc6ff7d4c0fd9a9592d17b727a5be218656905 (patch) | |
tree | e819c4dcff298a1d4877feb861fb1b4e11b7b6cf /common | |
parent | b5447ae736e9d16f92106df38737322cbf599166 (diff) | |
download | pentadactyl-49fc6ff7d4c0fd9a9592d17b727a5be218656905.tar.gz |
Automagically linkify error codes.
Diffstat (limited to 'common')
-rw-r--r-- | common/modules/template.jsm | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/common/modules/template.jsm b/common/modules/template.jsm index c08e98ba..8a398c2e 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -218,7 +218,7 @@ var Template = Module("Template", { XML.ignoreWhitespace = false; XML.prettyPrinting = false; type = type || (/^'.*'$/.test(token) ? "HelpOpt" : - /^\[.*\]$/.test(token) ? "HelpTopic" : + /^\[.*\]$|^E\d{3}$/.test(token) ? "HelpTopic" : /^:\w/.test(token) ? "HelpEx" : "HelpKey"); return <a highlight={"InlineHelpLink " + type} tag={topic} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{text || topic}</a>; @@ -237,13 +237,24 @@ var Template = Module("Template", { return <>{token}</>; XML.ignoreWhitespace = false; XML.prettyPrinting = false; - let tag = (/^'.*'$/.test(token) ? "o" : - /^\[.*\]$/.test(token) ? "t" : - /^:\w/.test(token) ? "ex" : "k"); + let tag = (/^'.*'$/.test(token) ? "o" : + /^\[.*\]$|^E\d{3}$/.test(token) ? "t" : + /^:\w/.test(token) ? "ex" : "k"); topic = topic.replace(/^'(.*)'$/, "$1"); return <{tag} xmlns={NS}>{topic}</{tag}>; }, + linkifyHelp: function linkifyHelp(str, help) { + let re = util.regexp(<![CDATA[ + (?P<pre> [/\s]|^) + (?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | [a-zA-Z]_\w+ | \[[\w-]+\] | E\d{3} ) + (?= [[\)!,:;./\s]|$) + ]]>, "gx"); + return this.highlightSubstrings(str, (function () { + for (let res in re.iterate(str)) + yield [res.index + res.pre.length, res.tag.length]; + })(), template[help ? "HelpLink" : "helpLink"]); + }, // if "processStrings" is true, any passed strings will be surrounded by " and // any line breaks are displayed as \n @@ -367,18 +378,6 @@ var Template = Module("Template", { // </e4x> }, - linkifyHelp: function linkifyHelp(str, help) { - let re = util.regexp(<![CDATA[ - (?P<pre> [/\s]|^) - (?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | [a-zA-Z]_\w+ | \[[\w-]+\] ) - (?= [[\)!,;./\s]|$) - ]]>, "gx"); - return this.highlightSubstrings(str, (function () { - for (let res in re.iterate(str)) - yield [res.index + res.pre.length, res.tag.length]; - })(), template[help ? "HelpLink" : "helpLink"]); - }, - options: function options(title, opts, verbose) { XML.ignoreWhitespace = false; XML.prettyPrinting = false; // <e4x> |