mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 20:04:11 +01:00
Add TOC to help pages.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user