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,37 +8,108 @@
|
|||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
xmlns:str="http://exslt.org/strings"
|
xmlns:str="http://exslt.org/strings"
|
||||||
xmlns:exsl="http://exslt.org/common"
|
xmlns:exsl="http://exslt.org/common"
|
||||||
extension-element-prefixes="str">
|
extension-element-prefixes="exsl str">
|
||||||
|
|
||||||
<xsl:output method="xml" indent="no"/>
|
<xsl:output method="xml" indent="no"/>
|
||||||
|
|
||||||
<!-- Variable Definitions {{{1 -->
|
<!-- 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:variable name="tags">
|
||||||
<xsl:text> </xsl:text>
|
<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:value-of select="concat(., ' ')"/>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:variable>
|
</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 -->
|
<!-- Root {{{1 -->
|
||||||
|
|
||||||
<xsl:template match="liberator:document">
|
<xsl:template match="/">
|
||||||
<html:html liberator:highlight="Help">
|
<xsl:for-each select="$root/liberator:document">
|
||||||
<html:head>
|
<html:html liberator:highlight="Help">
|
||||||
<html:title><xsl:value-of select="@title"/></html:title>
|
<html:head>
|
||||||
<html:base href="liberator://help/{@name}"/>
|
<html:title><xsl:value-of select="@title"/></html:title>
|
||||||
<html:script type="text/javascript"
|
<html:base href="liberator://help/{@name}"/>
|
||||||
src="chrome://liberator/content/help.js"/>
|
<html:script type="text/javascript"
|
||||||
</html:head>
|
src="chrome://liberator/content/help.js"/>
|
||||||
<html:body liberator:highlight="HelpBody">
|
</html:head>
|
||||||
<html:div class="liberator-logo"/>
|
<html:body liberator:highlight="HelpBody">
|
||||||
<xsl:call-template name="parse-tags">
|
<html:div class="liberator-logo"/>
|
||||||
<xsl:with-param name="text" select="concat(@name, '.html')"/>
|
<xsl:call-template name="parse-tags">
|
||||||
</xsl:call-template>
|
<xsl:with-param name="text" select="concat(@name, '.html')"/>
|
||||||
<xsl:apply-templates/>
|
</xsl:call-template>
|
||||||
</html:body>
|
<xsl:apply-templates/>
|
||||||
</html:html>
|
</html:body>
|
||||||
|
</html:html>
|
||||||
|
</xsl:for-each>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<!-- Table of Contents {{{1 -->
|
<!-- Table of Contents {{{1 -->
|
||||||
@@ -50,8 +121,8 @@
|
|||||||
<xsl:variable name="tag" select="concat('h', $level)"/>
|
<xsl:variable name="tag" select="concat('h', $level)"/>
|
||||||
<xsl:variable name="lasttag" select="concat('h', $level - 1)"/>
|
<xsl:variable name="lasttag" select="concat('h', $level - 1)"/>
|
||||||
|
|
||||||
<xsl:variable name="nodes" select="//liberator:*[
|
<xsl:variable name="nodes" select="//following-sibling::liberator:*[
|
||||||
local-name() = $tag and preceding::*[local-name() = $lasttag][position() = 1 and . = $context]]"/>
|
local-name() = $tag and preceding-sibling::*[local-name() = $lasttag][position() = 1 and . = $context]]"/>
|
||||||
|
|
||||||
<xsl:if test="$nodes">
|
<xsl:if test="$nodes">
|
||||||
<html:ol liberator:highlight="HelpOrderedList">
|
<html:ol liberator:highlight="HelpOrderedList">
|
||||||
@@ -76,13 +147,16 @@
|
|||||||
<xsl:copy>
|
<xsl:copy>
|
||||||
<xsl:apply-templates select="@*|node()"/>
|
<xsl:apply-templates select="@*|node()"/>
|
||||||
</xsl:copy>
|
</xsl:copy>
|
||||||
<html:div liberator:highlight="HelpTOC">
|
<xsl:if test="not($root//liberator:h1[2])">
|
||||||
<h2>Contents</h2>
|
<!-- Makes :help all impossibly slow. Why? -->
|
||||||
<xsl:call-template name="toc">
|
<html:div liberator:highlight="HelpTOC">
|
||||||
<xsl:with-param name="level" select="2"/>
|
<h2>Contents</h2>
|
||||||
<xsl:with-param name="context" select="."/>
|
<xsl:call-template name="toc">
|
||||||
</xsl:call-template>
|
<xsl:with-param name="level" select="2"/>
|
||||||
</html:div>
|
<xsl:with-param name="context" select="."/>
|
||||||
|
</xsl:call-template>
|
||||||
|
</html:div>
|
||||||
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<!-- Items {{{1 -->
|
<!-- Items {{{1 -->
|
||||||
@@ -273,59 +347,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</xsl:template>
|
</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 -->
|
<!-- Process Tree {{{1 -->
|
||||||
|
|
||||||
<xsl:template match="@*|node()" mode="pass-2">
|
<xsl:template match="@*|node()" mode="pass-2">
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ function Hints() //{{{
|
|||||||
V: Mode("View hint source in external editor", function (elem, loc) buffer.viewSource(loc, true), extended),
|
V: Mode("View hint source in external editor", function (elem, loc) buffer.viewSource(loc, true), extended),
|
||||||
y: Mode("Yank hint location", function (elem, loc) util.copyToClipboard(loc, true)),
|
y: Mode("Yank hint location", function (elem, loc) util.copyToClipboard(loc, true)),
|
||||||
Y: Mode("Yank hint description", function (elem) util.copyToClipboard(elem.textContent || "", true), extended),
|
Y: Mode("Yank hint description", function (elem) util.copyToClipboard(elem.textContent || "", true), extended),
|
||||||
c: Mode("Open context menu", function (elem) buffer.openContextMenu(elem), extended),
|
c: Mode("Open context menu", function (elem) buffer.openContextMenu(elem), extended),
|
||||||
i: Mode("Show image", function (elem) liberator.open(elem.src), images),
|
i: Mode("Show image", function (elem) liberator.open(elem.src), images),
|
||||||
I: Mode("Show image in a new tab", function (elem) liberator.open(elem.src, liberator.NEW_TAB), images)
|
I: Mode("Show image in a new tab", function (elem) liberator.open(elem.src, liberator.NEW_TAB), images)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -412,8 +412,7 @@ function Hints() //{{{
|
|||||||
if (!rect)
|
if (!rect)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
imgSpan = util.xmlToDom(<span highlight="Hint"/>, doc);
|
imgSpan = util.xmlToDom(<span highlight="Hint" liberator:class="HintImage" xmlns:liberator={NS}/>, doc);
|
||||||
imgSpan.setAttributeNS(NS.uri, "class", "HintImage");
|
|
||||||
imgSpan.style.left = (rect.left + offsetX) + "px";
|
imgSpan.style.left = (rect.left + offsetX) + "px";
|
||||||
imgSpan.style.top = (rect.top + offsetY) + "px";
|
imgSpan.style.top = (rect.top + offsetY) + "px";
|
||||||
imgSpan.style.width = (rect.right - rect.left) + "px";
|
imgSpan.style.width = (rect.right - rect.left) + "px";
|
||||||
|
|||||||
@@ -261,9 +261,9 @@
|
|||||||
<p>The following preferences are set:</p>
|
<p>The following preferences are set:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><link target="http://kb.mozillazine.org/Dom.popup_allowed_events">dom.popup_allowed_events</link></li>
|
<li><link topic="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 topic="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/Accessibility.typeaheadfind">accessibility.typeaheadfind</link></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- TODO: others? -->
|
<!-- TODO: others? -->
|
||||||
|
|||||||
Reference in New Issue
Block a user