hgbook

annotate xsl/base-html-stylesheet.xsl @ 564:0d5935744f87

Switch from LaTeX to XML for examples.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon Mar 09 21:39:23 2009 -0700 (2009-03-09)
parents
children 40025381bded
rev   line source
bos@557 1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
bos@557 2
bos@557 3 <xsl:param name="html.stylesheet">/support/styles.css</xsl:param>
bos@557 4 <xsl:param name="toc.section.depth">3</xsl:param>
bos@557 5 <xsl:param name="annotate.toc">0</xsl:param>
bos@557 6
bos@557 7 <xsl:param name="generate.id.attributes" select="1"></xsl:param>
bos@557 8 <xsl:param name="header.rule" select="0"></xsl:param>
bos@557 9 <xsl:param name="footer.rule" select="0"></xsl:param>
bos@557 10 <xsl:param name="html.cleanup" select="1"></xsl:param>
bos@557 11 <xsl:param name="admon.style"><xsl:text></xsl:text></xsl:param>
bos@557 12 <xsl:param name="admon.graphics" select="1"></xsl:param>
bos@557 13 <xsl:param name="admon.graphics.path">/support/figs/</xsl:param>
bos@557 14
bos@557 15 <xsl:template match="sect1" mode="toc">
bos@557 16 <xsl:param name="toc-context" select="."/>
bos@557 17 <xsl:call-template name="subtoc">
bos@557 18 <xsl:with-param name="toc-context" select="$toc-context"/>
bos@557 19 <xsl:with-param name="nodes"
bos@557 20 select="sect2|refentry|bridgehead[$bridgehead.in.toc != 0]"/>
bos@557 21 </xsl:call-template>
bos@557 22 </xsl:template>
bos@557 23
bos@557 24 <xsl:template match="sect2" mode="toc">
bos@557 25 <xsl:param name="toc-context" select="."/>
bos@557 26
bos@557 27 <xsl:call-template name="subtoc">
bos@557 28 <xsl:with-param name="toc-context" select="$toc-context"/>
bos@557 29 <xsl:with-param name="nodes"
bos@557 30 select="sect3|refentry|bridgehead[$bridgehead.in.toc != 0]"/>
bos@557 31 </xsl:call-template>
bos@557 32 </xsl:template>
bos@557 33
bos@557 34 <!-- Add id attributes to <p> tags. This is mostly a copy of the
bos@557 35 base XSL. -->
bos@557 36 <xsl:template name="paragraph">
bos@557 37 <xsl:param name="class" select="''"/>
bos@557 38 <xsl:param name="content"/>
bos@557 39
bos@557 40 <xsl:variable name="p">
bos@557 41 <p>
bos@557 42 <xsl:call-template name="dir"/>
bos@557 43 <xsl:if test="$class != ''">
bos@557 44 <xsl:apply-templates select="." mode="class.attribute">
bos@557 45 <xsl:with-param name="class" select="$class"/>
bos@557 46 </xsl:apply-templates>
bos@557 47 </xsl:if>
bos@557 48 <!-- Here we go. -->
bos@557 49 <xsl:if test="$generate.id.attributes != 0">
bos@557 50 <xsl:attribute name="id">
bos@557 51 <xsl:call-template name="object.id"/>
bos@557 52 </xsl:attribute>
bos@557 53 </xsl:if>
bos@557 54 <xsl:copy-of select="$content"/>
bos@557 55 </p>
bos@557 56 </xsl:variable>
bos@557 57
bos@557 58 <xsl:choose>
bos@557 59 <xsl:when test="$html.cleanup != 0">
bos@557 60 <xsl:call-template name="unwrap.p">
bos@557 61 <xsl:with-param name="p" select="$p"/>
bos@557 62 </xsl:call-template>
bos@557 63 </xsl:when>
bos@557 64 <xsl:otherwise>
bos@557 65 <xsl:copy-of select="$p"/>
bos@557 66 </xsl:otherwise>
bos@557 67 </xsl:choose>
bos@557 68 </xsl:template>
bos@557 69
bos@557 70 <!-- Add id attributes to <programlisting> and <screen> tags. Once
bos@557 71 again, this is mostly a copy of the base XSL, although rather
bos@557 72 trimmed down. -->
bos@557 73 <xsl:template match="programlisting|screen">
bos@557 74 <xsl:param name="suppress-numbers" select="'0'"/>
bos@557 75
bos@557 76 <xsl:call-template name="anchor"/>
bos@557 77
bos@557 78 <pre>
bos@557 79 <!-- Here we go. -->
bos@557 80 <xsl:if test="$generate.id.attributes != 0">
bos@557 81 <xsl:attribute name="id">
bos@557 82 <xsl:call-template name="object.id"/>
bos@557 83 </xsl:attribute>
bos@557 84 </xsl:if>
bos@557 85
bos@557 86 <xsl:apply-templates select="." mode="class.attribute"/>
bos@557 87 <xsl:call-template name="apply-highlighting"/>
bos@557 88 </pre>
bos@557 89 </xsl:template>
bos@557 90
bos@557 91 <!-- The default stylesheet generates a little TOC at the beginning
bos@557 92 of each qandaset. Uh, no thanks. -->
bos@557 93 <xsl:template name="process.qanda.toc"/>
bos@557 94
bos@557 95 <xsl:template name="user.header.navigation">
bos@557 96 <div class="navheader"><h2 class="booktitle"><a href="/">Mercurial: The Definitive Guide</a> <span class="authors">by Bryan O'Sullivan</span></h2></div>
bos@557 97 </xsl:template>
bos@557 98
bos@557 99 <xsl:template name="user.head.content">
bos@557 100 <link rel="alternate" type="application/atom+xml" title="Comments"
bos@557 101 href="/feeds/comments/"/>
bos@557 102 <link rel="shortcut icon" type="image/png" href="/support/figs/favicon.png"/>
bos@557 103 <script type="text/javascript" src="/support/jquery-min.js"></script>
bos@557 104 <script type="text/javascript" src="/support/form.js"></script>
bos@557 105 <script type="text/javascript" src="/support/hsbook.js"></script>
bos@557 106 </xsl:template>
bos@557 107
bos@557 108 <xsl:template name="user.footer.content">
bos@557 109 <div class="rwhfooter">
bos@557 110 <p><img src="/support/figs/rss.png"/> Want to stay up to date? Subscribe to the comment feed for <a id="chapterfeed" class="feed" href="/feeds/comments/">this chapter</a>, or the <a class="feed" href="/feeds/comments/">entire book</a>.</p>
bos@557 111 <p>Copyright 2009, Bryan O'Sullivan.
bos@557 112 Icons by <a href="mailto:mattahan@gmail.com">Paul Davey</a> aka <a href="http://mattahan.deviantart.com/">Mattahan</a>.</p>
bos@557 113 </div>
bos@557 114 </xsl:template>
bos@557 115
bos@557 116 <xsl:template name="user.footer.navigation">
bos@557 117 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
bos@557 118 <script type="text/javascript">_uacct = "UA-1805907-3"; urchinTracker();</script>
bos@557 119 </xsl:template>
bos@557 120 </xsl:stylesheet>