浏览代码

Automatized preface pages labeling.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7556 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Manuel Canales Esparcia 19 年之前
父节点
当前提交
dc931cb251

+ 1 - 1
prologue/audience.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-audience" label="ii">
+<sect1 id="pre-audience">
   <?dbhtml filename="audience.html"?>
 
   <title>Audience</title>

+ 1 - 1
prologue/errata.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-errata" label="vii">
+<sect1 id="pre-errata">
   <?dbhtml filename="errata.html"?>
 
   <title>Errata</title>

+ 1 - 1
prologue/foreword.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-foreword" label="i">
+<sect1 id="pre-foreword">
   <?dbhtml filename="foreword.html"?>
 
   <title>Foreword</title>

+ 1 - 1
prologue/hostreqs.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-hostreqs" label="iv">
+<sect1 id="pre-hostreqs">
   <?dbhtml filename="hostreqs.html"?>
 
   <title>Host System Requirements</title>

+ 1 - 1
prologue/organization.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-organization" label="vi">
+<sect1 id="pre-organization">
   <?dbhtml filename="organization.html"?>
 
   <title>Structure</title>

+ 1 - 1
prologue/prerequisites.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-prerequisites" label="iii">
+<sect1 id="pre-prerequisites">
   <?dbhtml filename="prerequisites.html"?>
 
   <title>Prerequisites</title>

+ 1 - 1
prologue/typography.xml

@@ -5,7 +5,7 @@
   %general-entities;
 ]>
 
-<sect1 id="pre-typography" label="v">
+<sect1 id="pre-typography">
   <?dbhtml filename="typography.html"?>
 
   <title>Typography</title>

+ 40 - 2
stylesheets/xhtml/lfs-sections.xsl

@@ -48,12 +48,50 @@
       <xsl:call-template name="process.chunk.footnotes"/>
     </div>
   </xsl:template>
-    
+
     <!-- Sections numbering -->
   <xsl:param name="section.autolabel" select="1"/>
   <xsl:param name="section.label.includes.component.label" select="1"/>
 
-    <!-- Skip numeraration for sections with empty title -->
+    <!-- Use lowercase roman numbers for sect1 in preface -->
+  <xsl:template match="sect1" mode="label.markup">
+    <!-- if the parent is a component, maybe label that too -->
+    <xsl:variable name="parent.is.component">
+      <xsl:call-template name="is.component">
+        <xsl:with-param name="node" select=".."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="component.label">
+      <xsl:if test="$section.label.includes.component.label != 0
+                    and $parent.is.component != 0">
+        <xsl:variable name="parent.label">
+          <xsl:apply-templates select=".." mode="label.markup"/>
+        </xsl:variable>
+        <xsl:if test="$parent.label != ''">
+          <xsl:apply-templates select=".." mode="label.markup"/>
+          <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
+        </xsl:if>
+      </xsl:if>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="@label">
+        <xsl:value-of select="@label"/>
+      </xsl:when>
+      <xsl:when test="$section.autolabel != 0">
+        <xsl:copy-of select="$component.label"/>
+        <xsl:choose>
+          <xsl:when test="ancestor::preface">
+            <xsl:number format="i" count="sect1"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:number format="1" count="sect1"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:template>
+
+    <!-- Skip numeration for sect2 with empty title -->
   <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
     <xsl:if test="string-length(title) > 0">
       <!-- label the parent -->