VirtualBox

Changeset 56363 in vbox


Ignore:
Timestamp:
Jun 11, 2015 2:43:56 PM (10 years ago)
Author:
vboxsync
Message:

docbook2latex.xsl: Emit nameddest for titles to sections/paragraphs/whatever with id attributes so we can jump directly to it when opening the PDF. Current stuff isn't 100 perfect for chapters, but it's hopefully better than nothing...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/docbook2latex.xsl

    r56198 r56363  
    112112\usepackage{nameref}
    113113\usepackage{graphicx}
     114\usepackage{hyperref}
    114115\usepackage{fancybox}
    115116\usepackage{fancyvrb}
     
    277278  </xsl:template>
    278279
     280  <!--
     281    Inserts \hypertarget{@id} that can be referenced via the /A "nameddest=@id"
     282    command line or #nameddest=@id URL parameter.
     283
     284    TODO: The placement of the target could be improved on. The raisebox
     285          stuff is a crude hack to make it a little more acceptable.  -->
     286  <xsl:template name="title-wrapper">
     287    <xsl:param name="texcmd" select="concat('\',name(..))"/>
     288    <xsl:param name="refid" select="../@id"/>
     289
     290    <xsl:call-template name="xsltprocNewlineOutputHack"/>
     291    <xsl:choose>
     292      <xsl:when test="$refid">
     293        <xsl:text>&#x0a;</xsl:text>
     294        <xsl:value-of select="$texcmd"/>
     295        <xsl:text>[</xsl:text> <!-- for toc -->
     296        <xsl:apply-templates />
     297        <xsl:text>]</xsl:text>
     298        <xsl:text>{</xsl:text> <!-- for doc -->
     299        <xsl:text>\raisebox{\ht\strutbox}{\hypertarget{</xsl:text>
     300        <xsl:value-of select="$refid"/>
     301        <xsl:text>}{}}</xsl:text>
     302        <xsl:apply-templates />
     303        <xsl:text>}</xsl:text>
     304      </xsl:when>
     305      <xsl:otherwise>
     306        <xsl:text>&#x0a;</xsl:text><xsl:value-of select="$texcmd"/><xsl:text>{</xsl:text>
     307        <xsl:apply-templates />
     308        <xsl:text>}</xsl:text>
     309      </xsl:otherwise>
     310    </xsl:choose>
     311  </xsl:template>
     312
    279313  <xsl:template match="title">
     314    <xsl:variable name="refid" select="../@id" />
    280315    <xsl:choose>
    281316      <xsl:when test="name(..)='bookinfo'">
     
    285320      </xsl:when>
    286321      <xsl:when test="name(..)='chapter'">
    287         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    288         <xsl:text>&#x0a;\chapter{</xsl:text>
    289         <xsl:apply-templates />
    290         <xsl:text>}</xsl:text>
     322        <xsl:call-template name="title-wrapper"/>
    291323      </xsl:when>
    292324      <xsl:when test="name(..)='sect1'">
    293         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    294         <xsl:text>&#x0a;\section{</xsl:text>
    295         <xsl:apply-templates />
    296         <xsl:text>}</xsl:text>
     325        <xsl:call-template name="title-wrapper">
     326          <xsl:with-param name="texcmd">\section</xsl:with-param>
     327        </xsl:call-template>
    297328      </xsl:when>
    298329      <xsl:when test="name(..)='sect2'">
    299         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    300         <xsl:text>&#x0a;\subsection{</xsl:text>
    301         <xsl:apply-templates />
    302         <xsl:text>}</xsl:text>
     330        <xsl:call-template name="title-wrapper">
     331          <xsl:with-param name="texcmd">\subsection</xsl:with-param>
     332        </xsl:call-template>
    303333      </xsl:when>
    304334      <xsl:when test="name(..)='sect3'">
    305         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    306         <xsl:text>&#x0a;\subsubsection{</xsl:text>
    307         <xsl:apply-templates />
    308         <xsl:text>}</xsl:text>
     335        <xsl:call-template name="title-wrapper">
     336          <xsl:with-param name="texcmd">\subsubsection</xsl:with-param>
     337        </xsl:call-template>
    309338      </xsl:when>
    310339      <xsl:when test="name(..)='sect4'">
    311         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    312         <xsl:text>&#x0a;\paragraph{</xsl:text>
    313         <xsl:apply-templates />
    314         <xsl:text>}</xsl:text>
     340        <xsl:call-template name="title-wrapper">
     341          <xsl:with-param name="texcmd">\paragraph</xsl:with-param>
     342        </xsl:call-template>
    315343      </xsl:when>
    316344      <xsl:when test="name(..)='sect5'">
    317         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    318         <xsl:text>&#x0a;\subparagraph{</xsl:text>
    319         <xsl:apply-templates />
    320         <xsl:text>}</xsl:text>
     345        <xsl:call-template name="title-wrapper">
     346          <xsl:with-param name="texcmd">\subparagraph</xsl:with-param>
     347        </xsl:call-template>
    321348      </xsl:when>
    322349      <xsl:when test="name(..)='refsect1'">
    323         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    324         <xsl:text>&#x0a;\paragraph{</xsl:text>
    325         <xsl:apply-templates />
    326         <xsl:text>}&#x0a;\begin{addmargin}{1em}&#x0a;</xsl:text> <!-- addmargin is ended by refsect1 template way further down. -->
     350        <xsl:call-template name="title-wrapper">
     351          <xsl:with-param name="texcmd">\paragraph</xsl:with-param>
     352        </xsl:call-template>
     353        <xsl:text>&#x0a;\begin{addmargin}{1em}&#x0a;</xsl:text> <!-- addmargin is ended by refsect1 template way further down. -->
    327354      </xsl:when>
    328355      <xsl:when test="name(..)='refsect2'">
    329         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    330         <xsl:text>&#x0a;\subparagraph{</xsl:text>
    331         <xsl:apply-templates />
    332         <xsl:text>}</xsl:text>
     356        <xsl:call-template name="title-wrapper">
     357          <xsl:with-param name="texcmd">\subparagraph</xsl:with-param>
     358        </xsl:call-template>
    333359      </xsl:when>
    334360      <xsl:when test="name(..)='appendix'">
    335         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    336         <xsl:text>&#x0a;\chapter{</xsl:text>
    337         <xsl:apply-templates />
    338         <xsl:text>}</xsl:text>
     361        <xsl:call-template name="title-wrapper">
     362          <xsl:with-param name="texcmd">\chapter</xsl:with-param>
     363        </xsl:call-template>
    339364      </xsl:when>
    340365      <xsl:when test="name(..)='glossdiv'">
    341         <xsl:call-template name="xsltprocNewlineOutputHack"/>
    342         <xsl:text>&#x0a;\section*{</xsl:text>
    343         <xsl:apply-templates />
    344         <xsl:text>}</xsl:text>
    345       </xsl:when>
    346     </xsl:choose>
    347     <xsl:variable name="refid" select="../@id" />
     366        <xsl:call-template name="title-wrapper">
     367          <xsl:with-param name="texcmd">\section*</xsl:with-param>
     368        </xsl:call-template>
     369      </xsl:when>
     370    </xsl:choose>
    348371    <xsl:if test="$refid">
    349372      <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette