diff options
author | Tim Yamin <plasmaroo@gentoo.org> | 2006-05-17 22:39:06 +0000 |
---|---|---|
committer | Tim Yamin <plasmaroo@gentoo.org> | 2006-05-17 22:39:06 +0000 |
commit | 44ac6b132e3f68ce1d3e3c8db659011bcfddaf2b (patch) | |
tree | 81521686a61d027cddea20f01537e6977f3e8c77 | |
parent | Lets not interject opinion (diff) | |
download | devmanual-44ac6b132e3f68ce1d3e3c8db659011bcfddaf2b.tar.gz devmanual-44ac6b132e3f68ce1d3e3c8db659011bcfddaf2b.tar.bz2 devmanual-44ac6b132e3f68ce1d3e3c8db659011bcfddaf2b.zip |
More highlighting goodies (SGML+C).
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/devmanual/trunk@49 176d3534-300d-0410-8db8-84e73ed771c3
-rw-r--r-- | devbook.xsl | 13 | ||||
-rw-r--r-- | ebuild-writing/text.xml | 1 | ||||
-rw-r--r-- | quickstart/text.xml | 1 | ||||
-rw-r--r-- | xsl/lang.highlight.c.xsl | 76 | ||||
-rw-r--r-- | xsl/lang.highlight.ebuild.xsl | 1 | ||||
-rw-r--r-- | xsl/lang.highlight.m4.xsl | 1 | ||||
-rw-r--r-- | xsl/lang.highlight.make.xsl | 1 | ||||
-rw-r--r-- | xsl/lang.highlight.sgml.xsl | 70 |
8 files changed, 159 insertions, 5 deletions
diff --git a/devbook.xsl b/devbook.xsl index d76aadd..bc9e506 100644 --- a/devbook.xsl +++ b/devbook.xsl @@ -5,9 +5,11 @@ exclude-result-prefixes="str exslt xsl"> <xsl:import href="xsl/str.tokenize.function.xsl"/> +<xsl:import href="xsl/lang.highlight.c.xsl"/> <xsl:import href="xsl/lang.highlight.ebuild.xsl"/> <xsl:import href="xsl/lang.highlight.make.xsl"/> <xsl:import href="xsl/lang.highlight.m4.xsl"/> +<xsl:import href="xsl/lang.highlight.sgml.xsl"/> <xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="yes"/> @@ -160,6 +162,16 @@ <xsl:with-param name="data" select="."/> </xsl:call-template> </xsl:when> + <xsl:when test="$lang = 'sgml'"> + <xsl:call-template name="lang.highlight.sgml.tokenate"> + <xsl:with-param name="data" select="."/> + </xsl:call-template> + </xsl:when> + <xsl:when test="$lang = 'c'"> + <xsl:call-template name="lang.highlight.c.tokenate"> + <xsl:with-param name="data" select="."/> + </xsl:call-template> + </xsl:when> <xsl:otherwise> <xsl:message>Error: Unknown language type (<xsl:value-of select="$lang"/>)</xsl:message> <xsl:value-of select="."/> @@ -392,7 +404,6 @@ <a href="http://validator.w3.org/check/referer"><img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-xhtml.png" alt="Valid XHTML 1.0" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-css.png" alt="Valid CSS" /></a> <a href="http://www.gentoo.org/"><img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-gentoo.png" alt="Powered by Gentoo" /></a> - <a href="http://www.gnu.org/software/emacs/emacs.html"><img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-emacs.png" alt="Hacked together using Emacs" /></a> <a href="http://creativecommons.org/licenses/by-sa/2.0/"><img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-creativecommons.png" alt="Creative Commons License" /></a> <img src="http://dev.gentoo.org/~plasmaroo/.icon_mini-xml.png" alt="XML Powered!"/> <br /> diff --git a/ebuild-writing/text.xml b/ebuild-writing/text.xml index b51d746..8ed134d 100644 --- a/ebuild-writing/text.xml +++ b/ebuild-writing/text.xml @@ -27,4 +27,5 @@ with some general notes and extended examples. <include href="variables/"/> <include href="using-eclasses/"/> <include href="functions/"/> +<include href="misc-files/"/> </guide> diff --git a/quickstart/text.xml b/quickstart/text.xml index 7bbdae5..7c6c943 100644 --- a/quickstart/text.xml +++ b/quickstart/text.xml @@ -400,7 +400,6 @@ src_unpack() { } src_compile() { - econf \ $(use_enable nls) \ $(use_enable ssl) \ diff --git a/xsl/lang.highlight.c.xsl b/xsl/lang.highlight.c.xsl new file mode 100644 index 0000000..7186ea7 --- /dev/null +++ b/xsl/lang.highlight.c.xsl @@ -0,0 +1,76 @@ +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:func="http://exslt.org/functions" + xmlns:exsl="http://exslt.org/common" + xmlns:str="http://exslt.org/strings" + extension-element-prefixes="str func exsl"> + + <xsl:template name="lang.highlight.c.subtokenate"> + <xsl:param name="data"/> + <xsl:param name="inPreProc"/> + <xsl:choose> + <xsl:when test="starts-with($data, '<') and substring($data, string-length($data)) = '>'"> + <span class="Identifier"><</span><span class="Constant"><xsl:value-of select="substring($data, 2, string-length($data)-2)"/></span><span class="Identifier">></span> + </xsl:when> + + <xsl:when test="$inPreProc = 'true'"> + <span class="PreProc"><xsl:value-of select="."/></span> + </xsl:when> + + <!-- No match return --> + <xsl:otherwise> + <xsl:value-of select="$data"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="lang.highlight.c.tokenate"> + <xsl:param name="data"/> + + <!-- Only tokenize spaces, this way we preserve tabs. --> + <xsl:variable name="tokenizedData" select="str:tokenize_plasmaroo($data, '" 	')"/> + + <!-- Scan for quotes... --> + <xsl:for-each select="exslt:node-set($tokenizedData)"> + <xsl:variable name="quotePos" select="count(../*[@delimiter='"' and position() < $myPos])"/> + <xsl:variable name="commentOpen" select="count(str:tokenize_plasmaroo(substring-before($data, concat(' ', '/*'))))"/> + <xsl:variable name="commentClosed" select="count(str:tokenize_plasmaroo(substring-before($data, concat(' ', '*/'))))"/> + + <xsl:variable name="macroLine"> + <xsl:if test="../*[position()=1] = '#ifdef' or ../*[position()=1] = '#include' or ../*[position()=1] = '#endif' or + ../*[position()=1] = '#elif' or ../*[position()=1] = '#pragma' or ../*[position()=1] = '#else' or + ../*[position()=1] = '#define'">true</xsl:if> + </xsl:variable> + + <xsl:choose> + <!-- Highlight a quote --> + <xsl:when test=". = '"'"> + <span class="Statement">"</span> + </xsl:when> + + <!-- If we're inside quotes stop here --> + <xsl:when test="$quotePos mod 2 != 0"> + <span class="Constant"> + <xsl:call-template name="lang.highlight.ebuild.subtokenate"> + <xsl:with-param name="data"><xsl:value-of select="."/></xsl:with-param> + <xsl:with-param name="nokeywords">True</xsl:with-param> + </xsl:call-template> + </span> + </xsl:when> + + <xsl:when test="$commentOpen != $commentClosed and position() > $commentOpen"> + <span class="Comment"><xsl:value-of select="."/></span> + </xsl:when> + + <!-- No match return --> + <xsl:otherwise> + <xsl:call-template name="lang.highlight.c.subtokenate"> + <xsl:with-param name="data" select="."/> + <xsl:with-param name="inPreProc" select="$macroLine"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </xsl:template> + +</xsl:stylesheet> diff --git a/xsl/lang.highlight.ebuild.xsl b/xsl/lang.highlight.ebuild.xsl index 8b841ab..888f9c5 100644 --- a/xsl/lang.highlight.ebuild.xsl +++ b/xsl/lang.highlight.ebuild.xsl @@ -413,7 +413,6 @@ </xsl:call-template> </xsl:otherwise> </xsl:choose> - <!-- <xsl:text> </xsl:text> --> </xsl:for-each> </xsl:template> diff --git a/xsl/lang.highlight.m4.xsl b/xsl/lang.highlight.m4.xsl index 146b89f..075929b 100644 --- a/xsl/lang.highlight.m4.xsl +++ b/xsl/lang.highlight.m4.xsl @@ -141,7 +141,6 @@ </xsl:call-template> </xsl:otherwise> </xsl:choose> - <!-- <xsl:text> </xsl:text> --> </xsl:for-each> </xsl:template> diff --git a/xsl/lang.highlight.make.xsl b/xsl/lang.highlight.make.xsl index fd84f53..58c8ea9 100644 --- a/xsl/lang.highlight.make.xsl +++ b/xsl/lang.highlight.make.xsl @@ -99,7 +99,6 @@ </xsl:call-template> </xsl:otherwise> </xsl:choose> - <!-- <xsl:text> </xsl:text> --> </xsl:for-each> </xsl:template> diff --git a/xsl/lang.highlight.sgml.xsl b/xsl/lang.highlight.sgml.xsl new file mode 100644 index 0000000..28af90f --- /dev/null +++ b/xsl/lang.highlight.sgml.xsl @@ -0,0 +1,70 @@ +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:func="http://exslt.org/functions" + xmlns:exsl="http://exslt.org/common" + xmlns:str="http://exslt.org/strings" + extension-element-prefixes="str func exsl"> + + <xsl:template name="lang.highlight.sgml.subtokenate"> + <xsl:param name="data"/> + <xsl:choose> + <xsl:when test="starts-with($data, '<') or substring($data, string-length($data)) = '>'"> + <span class="Identifier"><xsl:value-of select="$data"/></span> + </xsl:when> + + <!-- No match return --> + <xsl:otherwise> + <xsl:value-of select="$data"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="lang.highlight.sgml.tokenate"> + <xsl:param name="data"/> + + <!-- Only tokenize spaces, this way we preserve tabs. --> + <xsl:variable name="tokenizedData" select="str:tokenize_plasmaroo($data, '" 	<>')"/> + + <!-- Scan for quotes... --> + <xsl:for-each select="exslt:node-set($tokenizedData)"> + <xsl:variable name="myPos" select="position()"/> + <xsl:variable name="quotePos" select="count(../*[@delimiter='"' and position() < $myPos])"/> + <xsl:variable name="tagPosOpen" select="count(../*[@delimiter='<' and position() < $myPos])"/> + <xsl:variable name="tagPosClosed" select="count(../*[@delimiter='>' and position() < $myPos])"/> + + <xsl:choose> + <!-- Highlight a quote --> + <xsl:when test=". = '"'"> + <span class="Statement">"</span> + </xsl:when> + + <!-- If we're inside quotes stop here --> + <xsl:when test="$quotePos mod 2 != 0"> + <span class="Constant"> + <xsl:value-of select="."/> + </span> + </xsl:when> + + <xsl:when test="contains(., '=') and $tagPosOpen != $tagPosClosed"> + <span class="Identifier"><xsl:value-of select="substring-before(., '=')"/></span> + <span class="Constant">=</span> + <xsl:call-template name="lang.highlight.sgml.subtokenate"> + <xsl:with-param name="data" select="substring-after(., '=')"/> + </xsl:call-template> + </xsl:when> + + <xsl:when test="$tagPosOpen != $tagPosClosed"> + <span class="Identifier"><xsl:value-of select="."/></span> + </xsl:when> + + <!-- No match return --> + <xsl:otherwise> + <xsl:call-template name="lang.highlight.sgml.subtokenate"> + <xsl:with-param name="data" select="."/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </xsl:template> + +</xsl:stylesheet> |