mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 12:17:58 +01:00
Move to a two-stage parser for the help.
This commit is contained in:
@@ -8,22 +8,92 @@
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:str="http://exslt.org/strings"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
extension-element-prefixes="str">
|
||||
extension-element-prefixes="exsl str">
|
||||
|
||||
<xsl:output method="xml" indent="no"/>
|
||||
|
||||
<!-- Variable Definitions {{{1 -->
|
||||
|
||||
<xsl:variable name="doc">
|
||||
<xsl:apply-templates select="/liberator:document" mode="overlay"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="root" select="exsl:node-set($doc)"/>
|
||||
|
||||
<xsl:variable name="tags">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:for-each select="//@tag|//liberator:tags/text()|//liberator:tag/text()">
|
||||
<xsl:for-each select="$root//@tag|$root//liberator:tags/text()|$root//liberator:tag/text()">
|
||||
<xsl:value-of select="concat(., ' ')"/>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- Process Overlays {{{1 -->
|
||||
|
||||
<xsl:variable name="overlay" select="concat('liberator://help-overlay/', /liberator:document/@name)"/>
|
||||
<xsl:variable name="overlaydoc" select="document($overlay)/liberator:overlay"/>
|
||||
|
||||
<xsl:template name="splice-overlays">
|
||||
<xsl:param name="elem"/>
|
||||
<xsl:param name="tag"/>
|
||||
<xsl:for-each select="$overlaydoc/*[@insertbefore=$tag]">
|
||||
<xsl:apply-templates select="." mode="overlay"/>
|
||||
</xsl:for-each>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$overlaydoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$overlaydoc/*[@replace=$tag]">
|
||||
<xsl:apply-templates select="." mode="overlay-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select="$elem">
|
||||
<xsl:apply-templates select="." mode="overlay-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="$overlaydoc/*[@insertafter=$tag]">
|
||||
<xsl:apply-templates select="." mode="overlay"/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:tags[parent::liberator:document]|liberator:tag" mode="overlay">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(., ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="*[liberator:tags]" mode="overlay">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(liberator:tags, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:*[@tag and not(@replace)]" mode="overlay">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Process Inclusions {{{1 -->
|
||||
|
||||
<xsl:template match="liberator:include" mode="overlay-2">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="document(@href)/liberator:document/node()" mode="overlay"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@*|node()" mode="overlay">
|
||||
<xsl:apply-templates select="." mode="overlay-2"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="@*|node()" mode="overlay-2">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" mode="overlay"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Root {{{1 -->
|
||||
|
||||
<xsl:template match="liberator:document">
|
||||
<xsl:template match="/">
|
||||
<xsl:for-each select="$root/liberator:document">
|
||||
<html:html liberator:highlight="Help">
|
||||
<html:head>
|
||||
<html:title><xsl:value-of select="@title"/></html:title>
|
||||
@@ -39,6 +109,7 @@
|
||||
<xsl:apply-templates/>
|
||||
</html:body>
|
||||
</html:html>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Table of Contents {{{1 -->
|
||||
@@ -50,8 +121,8 @@
|
||||
<xsl:variable name="tag" select="concat('h', $level)"/>
|
||||
<xsl:variable name="lasttag" select="concat('h', $level - 1)"/>
|
||||
|
||||
<xsl:variable name="nodes" select="//liberator:*[
|
||||
local-name() = $tag and preceding::*[local-name() = $lasttag][position() = 1 and . = $context]]"/>
|
||||
<xsl:variable name="nodes" select="//following-sibling::liberator:*[
|
||||
local-name() = $tag and preceding-sibling::*[local-name() = $lasttag][position() = 1 and . = $context]]"/>
|
||||
|
||||
<xsl:if test="$nodes">
|
||||
<html:ol liberator:highlight="HelpOrderedList">
|
||||
@@ -76,6 +147,8 @@
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
<xsl:if test="not($root//liberator:h1[2])">
|
||||
<!-- Makes :help all impossibly slow. Why? -->
|
||||
<html:div liberator:highlight="HelpTOC">
|
||||
<h2>Contents</h2>
|
||||
<xsl:call-template name="toc">
|
||||
@@ -83,6 +156,7 @@
|
||||
<xsl:with-param name="context" select="."/>
|
||||
</xsl:call-template>
|
||||
</html:div>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Items {{{1 -->
|
||||
@@ -273,59 +347,6 @@
|
||||
</form>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Process Inclusions {{{1 -->
|
||||
|
||||
<xsl:template match="liberator:include" mode="pass-2">
|
||||
<xsl:apply-templates select="document(@href)/liberator:document/node()"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Process Overlays {{{1 -->
|
||||
|
||||
<xsl:variable name="overlay" select="concat('liberator://help-overlay/', /liberator:document/@name)"/>
|
||||
<xsl:variable name="overlaydoc" select="document($overlay)/liberator:overlay"/>
|
||||
|
||||
<xsl:template name="splice-overlays">
|
||||
<xsl:param name="elem"/>
|
||||
<xsl:param name="tag"/>
|
||||
<xsl:for-each select="$overlaydoc/*[@insertbefore=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$overlaydoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$overlaydoc/*[@replace=$tag]">
|
||||
<xsl:apply-templates select="." mode="pass-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:for-each select="$elem">
|
||||
<xsl:apply-templates select="." mode="pass-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="$overlaydoc/*[@insertafter=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:document/liberator:tags|liberator:document/liberator:tag">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(., ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:document/*[liberator:tags]">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(liberator:tags, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:*[@tag and not(@replace)]">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Process Tree {{{1 -->
|
||||
|
||||
<xsl:template match="@*|node()" mode="pass-2">
|
||||
|
||||
@@ -412,8 +412,7 @@ function Hints() //{{{
|
||||
if (!rect)
|
||||
continue;
|
||||
|
||||
imgSpan = util.xmlToDom(<span highlight="Hint"/>, doc);
|
||||
imgSpan.setAttributeNS(NS.uri, "class", "HintImage");
|
||||
imgSpan = util.xmlToDom(<span highlight="Hint" liberator:class="HintImage" xmlns:liberator={NS}/>, doc);
|
||||
imgSpan.style.left = (rect.left + offsetX) + "px";
|
||||
imgSpan.style.top = (rect.top + offsetY) + "px";
|
||||
imgSpan.style.width = (rect.right - rect.left) + "px";
|
||||
|
||||
@@ -261,9 +261,9 @@
|
||||
<p>The following preferences are set:</p>
|
||||
|
||||
<ul>
|
||||
<li><link target="http://kb.mozillazine.org/Dom.popup_allowed_events">dom.popup_allowed_events</link></li>
|
||||
<li><link target="http://kb.mozillazine.org/Accessibility.typeaheadfind.autostart">accessibility.typeaheadfind.autostart</link></li>
|
||||
<li><link target="http://kb.mozillazine.org/Accessibility.typeaheadfind">accessibility.typeaheadfind</link></li>
|
||||
<li><link topic="http://kb.mozillazine.org/Dom.popup_allowed_events">dom.popup_allowed_events</link></li>
|
||||
<li><link topic="http://kb.mozillazine.org/Accessibility.typeaheadfind.autostart">accessibility.typeaheadfind.autostart</link></li>
|
||||
<li><link topic="http://kb.mozillazine.org/Accessibility.typeaheadfind">accessibility.typeaheadfind</link></li>
|
||||
</ul>
|
||||
|
||||
<!-- TODO: others? -->
|
||||
|
||||
Reference in New Issue
Block a user