diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2022-05-15 09:57:23 -0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2022-05-15 16:12:22 +0200 |
commit | 1d913c170c5e0ef185b1e964fe4faaacc42b1616 (patch) | |
tree | e005497cf4ec55125b17bd5ab424f4ac608b21be /help3xsl | |
parent | 4d4f563ca60a0dffe6a29c010bb6d833bb2abb91 (diff) |
Refactor XSLT for code colorization
Change-Id: Ia619b7b0b1548c9de0b183a731e0cca3033eb529
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/134349
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
Diffstat (limited to 'help3xsl')
-rw-r--r-- | help3xsl/online_transform.xsl | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index ab703aaca8..efce9b608f 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -859,6 +859,33 @@ <br/> </xsl:template> +<!--SQLCODE, BASCODE, PYCODE--> +<xsl:template match="bascode | pycode | sqlcode"> + <xsl:variable name="codelangclass"> + <xsl:choose> + <xsl:when test="local-name()='bascode'"><xsl:text>language-visual-basic line-numbers</xsl:text></xsl:when> + <xsl:when test="local-name()='pycode'"><xsl:text>language-python line-numbers</xsl:text></xsl:when> + <xsl:when test="local-name()='sqlcode'"><xsl:text>language-sql</xsl:text></xsl:when> + </xsl:choose> + </xsl:variable> + <div class="{local-name()}" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> + <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> + <pre dir="auto"><code class="{$codelangclass}"><xsl:apply-templates /></code></pre> + </div> +</xsl:template> +<xsl:template match="bascode | pycode | sqlcode" mode="embedded"> + <xsl:variable name="codelangclass"> + <xsl:choose> + <xsl:when test="local-name()='bascode'"><xsl:text>language-visual-basic line-numbers</xsl:text></xsl:when> + <xsl:when test="local-name()='pycode'"><xsl:text>language-python line-numbers</xsl:text></xsl:when> + <xsl:when test="local-name()='sqlcode'"><xsl:text>language-sql</xsl:text></xsl:when> + </xsl:choose> + </xsl:variable> + <div class="{local-name()}" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> + <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> + <pre dir="auto"><code class="{$codelangclass}"><xsl:apply-templates /></code></pre> + </div> +</xsl:template> <!-- In case of missing help files --> <xsl:template match="help-id-missing"> <span id="bm_HID2"></span> @@ -977,44 +1004,6 @@ <p id="{@id}" class="{$role}" dir="auto"><xsl:apply-templates /></p> </xsl:template> -<xsl:template match="bascode"> - <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-visual-basic line-numbers"><xsl:apply-templates /></code></pre> - </div> -</xsl:template> -<xsl:template match="bascode" mode="embedded"> - <div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-visual-basic line-numbers"><xsl:apply-templates mode="embedded" /></code></pre> - </div> -</xsl:template> -<xsl:template match="pycode"> - <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-python line-numbers"><xsl:apply-templates /></code></pre> - </div> -</xsl:template> -<xsl:template match="pycode" mode="embedded"> - <div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-python line-numbers"><xsl:apply-templates mode="embedded" /></code></pre> - </div> -</xsl:template> - -<xsl:template match="sqlcode"> - <div class="sqlcode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-sql"><xsl:apply-templates /></code></pre> - </div> -</xsl:template> -<xsl:template match="sqlcode" mode="embedded"> - <div class="sqlcode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet"> - <xsl:attribute name="data-tooltip"><xsl:value-of select="$ui_copyclip"/></xsl:attribute> - <pre dir="auto"><code class="language-sql"><xsl:apply-templates mode="embedded" /></code></pre> - </div> -</xsl:template> - <!-- Insert Logo code snippet --> <xsl:template name="insertlogocode"> <pre dir="auto"><xsl:apply-templates /></pre> |