From 49fc6ff7d4c0fd9a9592d17b727a5be218656905 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 7 Mar 2011 22:33:53 -0500 Subject: [PATCH] Automagically linkify error codes. --- common/modules/template.jsm | 31 +++++++++++++++---------------- 1 file 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 {text || topic}; @@ -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}; }, + linkifyHelp: function linkifyHelp(str, help) { + let re = util.regexp( [/\s]|^) + (?P '[\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", { // }, - linkifyHelp: function linkifyHelp(str, help) { - let re = util.regexp( [/\s]|^) - (?P '[\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; //