diff options
-rw-r--r-- | source/02_augment/commits.xsl | 1 | ||||
-rw-r--r-- | source/99_result/main.css | 1 | ||||
-rw-r--r-- | utility/formatter.xsl | 59 |
3 files changed, 58 insertions, 3 deletions
diff --git a/source/02_augment/commits.xsl b/source/02_augment/commits.xsl index e9c4ae8..a2ad0b5 100644 --- a/source/02_augment/commits.xsl +++ b/source/02_augment/commits.xsl @@ -56,7 +56,6 @@ <xsl:template match="content[@type = 'text']/text()" mode="commit"> <xsl:call-template name="formatter"> - <xsl:with-param name="format">markdown</xsl:with-param> <xsl:with-param name="source" select="."/> </xsl:call-template> </xsl:template> diff --git a/source/99_result/main.css b/source/99_result/main.css index 942ee53..48889bc 100644 --- a/source/99_result/main.css +++ b/source/99_result/main.css @@ -10,6 +10,7 @@ p{margin:0 0 .5em 0;text-align:justify;line-height:1.75em} ul{margin:0;overflow:hidden} ul li{list-style-type:circle;line-height:1.5em} code{margin:0 .1em;padding:0 .5em;border:.1em solid #e3e8e8;background-color:#f8f8f8;border-radius:.3em} +pre{padding:1em;border-radius:.75em;color:#f8f8f2;background:#272822;white-space:pre-wrap} #content{max-width:45em;margin:auto} .info{font-size:.8em;margin-bottom:.5em;display:block} .info a{margin:0 .1em 0 .1em} diff --git a/utility/formatter.xsl b/utility/formatter.xsl index d2c2f7c..2c7f3b9 100644 --- a/utility/formatter.xsl +++ b/utility/formatter.xsl @@ -2,11 +2,12 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xalan="http://xml.apache.org/xalan" xmlns:InputXSLT="function.inputxslt.application" - exclude-result-prefixes="InputXSLT" + exclude-result-prefixes="xalan InputXSLT" > -<xsl:template name="formatter"> +<xsl:template name="plain_formatter"> <xsl:param name="format"/> <xsl:param name="source"/> @@ -16,4 +17,58 @@ )/self::command/node()"/> </xsl:template> +<xsl:template name="highlighter"> + <xsl:param name="source"/> + <xsl:param name="language"/> + + <xsl:variable name="formatted_code"> + <xsl:call-template name="plain_formatter"> + <xsl:with-param name="format"> + <xsl:text>highlight --out-format=xhtml --inline-css --style=molokai --fragment --enclose-pre --wrap-simple --syntax=</xsl:text> + <xsl:value-of select="$language"/> + </xsl:with-param> + <xsl:with-param name="source" select="$source"/> + </xsl:call-template> + </xsl:variable> + + <pre> + <xsl:copy-of select="xalan:nodeset($formatted_code)/pre/node()"/> + </pre> +</xsl:template> + +<xsl:template match="@*|node()" mode="embellish"> + <xsl:copy> + <xsl:apply-templates select="@*|node()" mode="embellish"/> + </xsl:copy> +</xsl:template> + +<xsl:template match="pre" mode="embellish"> + <xsl:call-template name="highlighter"> + <xsl:with-param name="source" select="code/text()"/> + <xsl:with-param name="language"> + <xsl:choose> + <xsl:when test="code/@class"> + <xsl:value-of select="substring(code/@class, 10, string-length(code/@class))"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>txt</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + +<xsl:template name="formatter"> + <xsl:param name="source"/> + + <xsl:variable name="content"> + <xsl:call-template name="plain_formatter"> + <xsl:with-param name="format">kramdown</xsl:with-param> + <xsl:with-param name="source" select="$source"/> + </xsl:call-template> + </xsl:variable> + + <xsl:apply-templates select="xalan:nodeset($content)" mode="embellish"/> +</xsl:template> + </xsl:stylesheet> |