1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-09 20:45:46 +01:00

Hack on :help NEWS.

This commit is contained in:
Kris Maglione
2011-02-19 07:17:54 -05:00
parent 73917f7cee
commit 2cef435dbc
3 changed files with 103 additions and 76 deletions

View File

@@ -687,19 +687,21 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
.responseText;
let re = util.regexp(<![CDATA[
^ (?P<space> \s*)
(?P<char> [-*+]) \ //
(?P<content> .*\n
(?: \1\ \ .*\n | \s*\n)* )
|
(?P<par>
(?: ^ [^\S\n]*
(?:[^-*+\s] | [-*+]\S)
.*\n
)+
)
|
(?: ^ [^\S\n]* \n) +
^ (?P<comment> \s* # .*\n)
| ^ (?P<space> \s*)
(?P<char> [-*+]) \ //
(?P<content> .*\n
(?: \2\ \ .*\n | \s*\n)* )
| (?P<par>
(?: ^ [^\S\n]*
(?:[^-*+\s] | [-*+]\S)
.*\n
)+
)
| (?: ^ [^\S\n]* \n) +
]]>, "gmxy");
let betas = util.regexp(/\[(b\d)\]/, "gx");
@@ -713,7 +715,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let list, space, i = 0;
for (let match in re.iterate(text)) {
if (match.char) {
if (match.comment)
continue;
else if (match.char) {
if (!list)
res += list = <ul/>;
let li = <li/>;
@@ -759,7 +763,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let body = rec(NEWS, 0);
for each (let li in body..li) {
let list = li..li.(@NS::highlight == "HelpNewsOld");
if (list.length() && list.length() == li..li.length()) {
if (list.length() && list.length() == li..li.(@NS::highlight != "").length()) {
for each (let li in list)
li.@NS::highlight = "";
li.@NS::highlight = "HelpNewsOld";

View File

@@ -196,28 +196,44 @@ var Template = Module("Template", {
// </e4x>
},
helpLink: function (topic, text, type) {
helpLink: function (token, text, type) {
if (!services["dactyl:"].initialized)
util.dactyl.initHelp();
let topic = token; // FIXME: Evil duplication!
if (/^\[.*\]$/.test(topic))
topic = topic.slice(1, -1);
else if (/^n_/.test(topic))
topic = topic.slice(2);
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
return <span highlight={type || ""}>{text || topic}</span>;
return <span highlight={type || ""}>{text || token}</span>;
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
type = type || (/^'.*'$/.test(topic) ? "HelpOpt" :
/^:\w/.test(topic) ? "HelpEx" : "HelpKey");
type = type || (/^'.*'$/.test(token) ? "HelpOpt" :
/^\[.*\]$/.test(token) ? "HelpTopic" :
/^:\w/.test(token) ? "HelpEx" : "HelpKey");
return <a highlight={type} tag={topic} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{text || topic}</a>;
},
HelpLink: function (topic) {
HelpLink: function (token) {
if (!services["dactyl:"].initialized)
util.dactyl.initHelp();
let topic = token; // FIXME: Evil duplication!
if (/^\[.*\]$/.test(topic))
topic = topic.slice(1, -1);
else if (/^n_/.test(topic))
topic = topic.slice(2);
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
return <>{topic}</>;
return <>{token}</>;
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
let tag = (/^'.*'$/.test(topic) ? "o" :
/^:\w/.test(topic) ? "ex" : "k");
let tag = (/^'.*'$/.test(token) ? "o" :
/^\[.*\]$/.test(token) ? "t" :
/^:\w/.test(token) ? "ex" : "k");
topic = topic.replace(/^'(.*)'$/, "$1");
return <{tag} xmlns={NS}>{topic}</{tag}>;
},
@@ -347,7 +363,7 @@ var Template = Module("Template", {
linkifyHelp: function linkifyHelp(str, help) {
let re = util.regexp(<![CDATA[
(?P<pre> [/\s]|^)
(?P<tag> '[\w-]+' | :(?:[\w-]+|!) | (?:._)?<[\w-]+> )
(?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | [a-zA-Z]_\w+ | \[[\w-]+\] )
(?= [[\)!,;./\s]|$)
]]>, "gx");
return this.highlightSubstrings(str, (function () {