summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <kris@vimperator.org>2009-10-30 02:04:15 -0400
committerKris Maglione <kris@vimperator.org>2009-10-30 02:04:15 -0400
commit7449d40f73157f2c3e861311c9b5a1ad99d8b4f5 (patch)
tree4b87572a963c98ad1a42334a6bd2916fdf767df5 /common
parent2ffbe6005e3701ab473df1b6615ce9e8e3bd429c (diff)
downloadpentadactyl-7449d40f73157f2c3e861311c9b5a1ad99d8b4f5.tar.gz
Add TOC to help pages.
Diffstat (limited to 'common')
-rw-r--r--common/content/help.xsl46
-rw-r--r--common/content/style.js13
2 files changed, 53 insertions, 6 deletions
diff --git a/common/content/help.xsl b/common/content/help.xsl
index 41f53329..270d1674 100644
--- a/common/content/help.xsl
+++ b/common/content/help.xsl
@@ -32,6 +32,47 @@
<xsl:apply-templates select="document(@href)/liberator:document/node()"/>
</xsl:template>
+ <xsl:template match="liberator:h1" mode="pass-2">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ <html:div liberator:highlight="HelpTOC">
+ <h2>Contents</h2>
+ <xsl:call-template name="toc">
+ <xsl:with-param name="level" select="2"/>
+ </xsl:call-template>
+ </html:div>
+ </xsl:template>
+ <xsl:template name="toc">
+ <xsl:param name="level"/>
+ <xsl:param name="context" select="false()"/>
+
+ <xsl:variable name="tag" select="concat('h', $level)"/>
+ <xsl:variable name="lasttag" select="concat('h', $level - 1)"/>
+
+ <xsl:variable name="nodes" select="//liberator:document/liberator:*[
+ local-name() = $tag and preceding-sibling::*[local-name() = $lasttag][not($context) or (position() = 1 and . = $context)]]"/>
+
+ <xsl:if test="$nodes">
+ <html:ol liberator:highlight="HelpOrderedList">
+ <xsl:for-each select="$nodes">
+ <li>
+ <html:a>
+ <xsl:if test="@tag">
+ <xsl:attribute name="href"><xsl:value-of select="concat('#', substring-before(concat(@tag, ' '), ' '))"/></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="node()"/>
+ </html:a>
+ <xsl:call-template name="toc">
+ <xsl:with-param name="level" select="$level + 1"/>
+ <xsl:with-param name="context" select="."/>
+ </xsl:call-template>
+ </li>
+ </xsl:for-each>
+ </html:ol>
+ </xsl:if>
+ </xsl:template>
+
<xsl:template match="liberator:dl" mode="pass-2">
<xsl:copy>
<column/>
@@ -145,8 +186,11 @@
</xsl:call-template>
</xsl:copy>
</xsl:template>
+ <xsl:template match="liberator:ul" mode="pass-2">
+ <html:ul liberator:highlight="HelpList"><xsl:apply-templates select="@*|node()"/></html:ul>
+ </xsl:template>
<xsl:template match="liberator:ol" mode="pass-2">
- <html:ol><xsl:apply-templates select="@*|node()"/></html:ol>
+ <html:ol liberator:highlight="HelpOrderedList"><xsl:apply-templates select="@*|node()"/></html:ol>
</xsl:template>
<xsl:template match="liberator:ex" mode="pass-2">
<xsl:copy>
diff --git a/common/content/style.js b/common/content/style.js
index 0fc4779b..d006ce02 100644
--- a/common/content/style.js
+++ b/common/content/style.js
@@ -154,9 +154,9 @@ Highlights.prototype.CSS = <![CDATA[
HelpLink,liberator|*>html|a text-decoration: none;
HelpLink:hover text-decoration: underline;
- HelpList,liberator|ul display: block; list-style: outside disc;
- HelpOrderedList,liberator|*>html:ol display: block; list-style: outside decimal;
- HelpListItem,liberator|li display: list-item; margin-left: 1.5em;
+ HelpList display: block; list-style: outside disc;
+ HelpOrderedList display: block; list-style: outside decimal;
+ HelpListItem,liberator|li display: list-item;
HelpNote,liberator|note display: block; margin: 1em 0em;
HelpNote::before content: "Note: "; color: red; font-weight: bold;
@@ -175,6 +175,9 @@ Highlights.prototype.CSS = <![CDATA[
HelpSubhead,liberator|h2 display: block; margin: 1em 0; padding-bottom: .2ex; border-bottom-width: 1px; font-size: 1.2em; font-weight: bold; color: #527BBD; clear: both;
HelpSubsubhead,liberator|h3 display: block; margin: 1em 0; padding-bottom: .2ex; font-size: 1.1em; font-weight: bold; color: #527BBD; clear: both;
+ HelpTOC
+ HelpTOC>ol ol margin-left: -1em;
+
HelpTab,liberator|dl display: table; width: 100%; margin: 1em 0; border-bottom-width: 1px; border-top-width: 1px; padding: .5ex 0; table-layout: fixed;
HelpTabColumn,liberator|column display: table-column;
HelpTabColumn:first-child width: 25%;
@@ -304,7 +307,7 @@ function Highlights(name, store)
.split("\n").filter(function (s) /\S/.test(s))
.forEach(function (style)
{
- style = Highlight.apply(Highlight, Array.slice(style.match(/^\s*([^,\s]+)(?:,([^,\s]+)?)?(?:,([^,\s]+))?\s*(.*)$/), 1));
+ style = Highlight.apply(Highlight, Array.slice(style.match(/^\s*((?:[^,\s]|\s\S)+)(?:,((?:[^,\s]|\s\S)+)?)?(?:,((?:[^,\s]|\s\S)+))?\s*(.*)$/), 1));
if (/^[>+ ]/.test(style.selector))
style.selector = self.selector(style.class) + style.selector;
@@ -785,7 +788,7 @@ liberator.registerObserver("load_commands", function () {
args.completeArg = args.completeArg > 1 ? -1 : 0;
if (args.completeArg == 0)
- context.completions = [[v.class, ""] for (v in highlight)];
+ context.completions = [[v.class, v.value] for (v in highlight)];
else if (args.completeArg == 1)
{
let hl = highlight.get(args[0]);