aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Yamin <plasmaroo@gentoo.org>2006-03-09 20:09:28 +0000
committerTim Yamin <plasmaroo@gentoo.org>2006-03-09 20:09:28 +0000
commitcbb4c933a0323fcaa84262b69849fbf52ac2e336 (patch)
tree56dccd3f29e15894020cfe5c810656e9de4672f4
parentFix code highlighting if we start with tabs rather than whitespace. (diff)
downloaddevmanual-cbb4c933a0323fcaa84262b69849fbf52ac2e336.tar.gz
devmanual-cbb4c933a0323fcaa84262b69849fbf52ac2e336.tar.bz2
devmanual-cbb4c933a0323fcaa84262b69849fbf52ac2e336.zip
Add optional line numbering to the syntax highlighter.
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/devmanual/trunk@23 176d3534-300d-0410-8db8-84e73ed771c3
-rw-r--r--devbook.xsl12
-rw-r--r--tasks-reference/completion/text.xml4
2 files changed, 10 insertions, 6 deletions
diff --git a/devbook.xsl b/devbook.xsl
index c2251ae..dafc746 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -90,8 +90,7 @@
<xsl:call-template name="highlight-subtokenate">
<xsl:with-param name="data" select="substring-before(substring-after($data, '--'), ')')"/>
</xsl:call-template>
- </span>
- )<xsl:value-of select="substring-after(substring-after($data, '--'), ')')"/>
+ </span>)<xsl:value-of select="substring-after(substring-after($data, '--'), ')')"/>
</xsl:when>
<xsl:otherwise>
<span class="Comment">
@@ -520,10 +519,15 @@
<!-- FIXME: Handle lang=... -->
<xsl:template match="codesample">
<pre><span class="Constant">
+ <xsl:variable name="numbering" select="@numbering"/>
<xsl:for-each select="str:tokenize_plasmaroo(., $newline)">
<xsl:choose>
- <xsl:when test=". = $newline and position() = 1"/>
- <xsl:when test=". = $newline"><xsl:value-of select='$newline'/></xsl:when>
+ <xsl:when test=". = $newline">
+ <xsl:if test="position() != 1"><xsl:value-of select='$newline'/></xsl:if>
+ <xsl:if test="$numbering = 'lines' and position() != last()-1">
+ <span style="float: left;"><xsl:number format="01"/>:<xsl:text> </xsl:text></span>
+ </xsl:if>
+ </xsl:when>
<xsl:otherwise>
<!-- <xsl:if test="position() != 1"><xsl:value-of select='$newline'/></xsl:if> -->
<xsl:call-template name="highlight-tokenate">
diff --git a/tasks-reference/completion/text.xml b/tasks-reference/completion/text.xml
index 216b293..7de4101 100644
--- a/tasks-reference/completion/text.xml
+++ b/tasks-reference/completion/text.xml
@@ -160,7 +160,7 @@ Nearly all completion functions will start out the same way. For these cases,
the following can be used as a template for creating new completion functions:
</p>
-<codesample lang="ebuild">
+<codesample lang="ebuild" numbering="lines">
_foo() {
local cur prev opts
COMPREPLY=()
@@ -302,7 +302,7 @@ real completion function for <c>revdep-rebuild</c> (might even be available in
<c>gentoo-bashcomp</c> by the time you read this :]).
</p>
-<codesample lang="ebuild">
+<codesample lang="ebuild" numbering="lines">
_revdep_rebuild() {
local cur prev opts
COMPREPLY=()