Commits

Jason McKesson  committed 8b2e035

Automatic TOC generation.

  • Participants
  • Parent commits c196760

Comments (0)

Files changed (2)

File docs/Load Docs.xpr

                                     <String xml:space="preserve">XSL</String>
                                 </field>
                                 <field name="url">
-                                    <String xml:space="preserve">Styles.xml</String>
+                                    <String xml:space="preserve">ToCreole.xsl</String>
+                                </field>
+                            </scenarioAssociation>
+                            <scenarioAssociation>
+                                <field name="name">
+                                    <String xml:space="preserve">ToCreole</String>
+                                </field>
+                                <field name="type">
+                                    <String xml:space="preserve">XSL</String>
+                                </field>
+                                <field name="url">
+                                    <String xml:space="preserve">New_Style_Step_By_Step.xml</String>
                                 </field>
                             </scenarioAssociation>
                             <scenarioAssociation>
                                     <String xml:space="preserve">XSL</String>
                                 </field>
                                 <field name="url">
-                                    <String xml:space="preserve">Style_Pointer_C.xml</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
-                                    <String xml:space="preserve">Style_Creation.xml</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
                                     <String xml:space="preserve">Structure_Reference.xml</String>
                                 </field>
                             </scenarioAssociation>
                                     <String xml:space="preserve">XSL</String>
                                 </field>
                                 <field name="url">
-                                    <String xml:space="preserve">Home.xml</String>
+                                    <String xml:space="preserve">Style%20Pointer%20C.xml</String>
+                                </field>
+                            </scenarioAssociation>
+                            <scenarioAssociation>
+                                <field name="name">
+                                    <String xml:space="preserve">ToCreole</String>
+                                </field>
+                                <field name="type">
+                                    <String xml:space="preserve">XSL</String>
+                                </field>
+                                <field name="url">
+                                    <String xml:space="preserve">Command%20Line%20Options.xml</String>
+                                </field>
+                            </scenarioAssociation>
+                            <scenarioAssociation>
+                                <field name="name">
+                                    <String xml:space="preserve">ToCreole</String>
+                                </field>
+                                <field name="type">
+                                    <String xml:space="preserve">XSL</String>
+                                </field>
+                                <field name="url">
+                                    <String xml:space="preserve">Extension%20Files.xml</String>
+                                </field>
+                            </scenarioAssociation>
+                            <scenarioAssociation>
+                                <field name="name">
+                                    <String xml:space="preserve">ToCreole</String>
+                                </field>
+                                <field name="type">
+                                    <String xml:space="preserve">XSL</String>
+                                </field>
+                                <field name="url">
+                                    <String xml:space="preserve">Command_Line_Options.xml</String>
+                                </field>
+                            </scenarioAssociation>
+                            <scenarioAssociation>
+                                <field name="name">
+                                    <String xml:space="preserve">ToCreole</String>
+                                </field>
+                                <field name="type">
+                                    <String xml:space="preserve">XSL</String>
+                                </field>
+                                <field name="url">
+                                    <String xml:space="preserve">Common_Extension_Files.xml</String>
                                 </field>
                             </scenarioAssociation>
                             <scenarioAssociation>
                                     <String xml:space="preserve">XSL</String>
                                 </field>
                                 <field name="url">
-                                    <String xml:space="preserve">Common_Extension_Files.xml</String>
+                                    <String xml:space="preserve">Style_Pointer_C.xml</String>
                                 </field>
                             </scenarioAssociation>
                             <scenarioAssociation>
                                     <String xml:space="preserve">XSL</String>
                                 </field>
                                 <field name="url">
-                                    <String xml:space="preserve">Command_Line_Options.xml</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
-                                    <String xml:space="preserve">ToCreole.xsl</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
-                                    <String xml:space="preserve">Extension%20Files.xml</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
-                                    <String xml:space="preserve">Command%20Line%20Options.xml</String>
-                                </field>
-                            </scenarioAssociation>
-                            <scenarioAssociation>
-                                <field name="name">
-                                    <String xml:space="preserve">ToCreole</String>
-                                </field>
-                                <field name="type">
-                                    <String xml:space="preserve">XSL</String>
-                                </field>
-                                <field name="url">
-                                    <String xml:space="preserve">Style%20Pointer%20C.xml</String>
+                                    <String xml:space="preserve">Styles.xml</String>
                                 </field>
                             </scenarioAssociation>
                         </scenarioAssociation-array>
                                     <Boolean xml:space="preserve">true</Boolean>
                                 </field>
                                 <field name="xsltParams">
-                                    <list/>
+                                    <list>
+                                    <transformationParameter>
+                                    <field name="paramDescription">
+                                    <paramDescriptor>
+                                    <field name="localName">
+                                    <String xml:space="preserve">basename</String>
+                                    </field>
+                                    <field name="prefix">
+                                    <null/>
+                                    </field>
+                                    <field name="namespace">
+                                    <null/>
+                                    </field>
+                                    </paramDescriptor>
+                                    </field>
+                                    <field name="value">
+                                    <String xml:space="preserve">${cfn}</String>
+                                    </field>
+                                    </transformationParameter>
+                                    </list>
                                 </field>
                                 <field name="cascadingStylesheets">
                                     <String-array/>

File docs/ToCreole.xsl

     <xsl:output name="text" method="text" encoding="UTF-8"/>
     
     <xsl:param name="filePrefix"/>
+    <xsl:param name="basename"/>
     
     
     <xsl:template match="/">
     
     <!-- Process the actual text data. -->
     <xsl:template match="db:para" mode="file">
+        <xsl:variable name="listCount" select="count(ancestor::db:listitem)"/>
         <xsl:if test="ancestor::db:blockquote or ancestor::db:epigraph">
             <xsl:text>-></xsl:text>
         </xsl:if>
         <xsl:if test="ancestor::db:itemizedlist and not(preceding-sibling::*)">
-            <xsl:text>* </xsl:text>
+            <xsl:value-of select="pg:dup('*', $listCount)"/>
+            <xsl:text> </xsl:text>
         </xsl:if>
         <xsl:if test="ancestor::db:orderedlist and not(preceding-sibling::*)">
-            <xsl:text># </xsl:text>
+            <xsl:value-of select="pg:dup('#', $listCount)"/>
+            <xsl:text> </xsl:text>
         </xsl:if>
         <xsl:apply-templates select="*|text()" mode="#current"/>
         <xsl:choose>
                 <xsl:text>
 </xsl:text>
             </xsl:when>
-            <xsl:when test="ancestor::db:listitem and following-sibling::*">
+            <xsl:when test="ancestor::db:listitem and following-sibling::* and
+                not(following-sibling::db:itemizedlist or following-sibling::db:orderedlist)">
                 <xsl:text>\\</xsl:text>
             </xsl:when>
+            <xsl:when test="ancestor::db:listitem and
+                (following-sibling::db:itemizedlist or following-sibling::db:orderedlist)">
+                <xsl:text>
+</xsl:text>
+            </xsl:when>
             <xsl:when test="parent::db:glossdef or following-sibling::*">
                 <xsl:text>
 
         <xsl:text>**//</xsl:text>
     </xsl:template>
     
-    <xsl:template match="db:phrase[@role='toc']" mode="file">
-        <xsl:text><![CDATA[<<toc>>]]></xsl:text>
-    </xsl:template>
-    
     <xsl:template match="db:citetitle" mode="file">
         <xsl:text>//**</xsl:text>
         <xsl:apply-templates select="*|text()" mode="#current"/>
     </xsl:template>
     
     <xsl:template match="db:title" mode="file"/>
+
+    <xsl:template match="db:phrase[@role='toc']" mode="file">
+        <xsl:apply-templates select="/descendant::db:section" mode="toc"/>
+    </xsl:template>
+    
+    <xsl:template match="db:section" mode="toc">
+        <xsl:variable name="title" select="db:title/text()"/>
+        <xsl:variable name="link" select="lower-case(replace($title, ' ', '-'))"/>
+        <xsl:variable name="starCount" select="count(ancestor-or-self::db:section)"/>
+        <xsl:value-of select="pg:dup('*', $starCount)"/>
+        <xsl:text> </xsl:text>
+        <xsl:text>[[</xsl:text>
+        <xsl:value-of select="$basename"/>
+        <xsl:text>#!</xsl:text>
+        <xsl:value-of select="$link"/>
+        <xsl:text>|</xsl:text>
+        <xsl:value-of select="$title"/>
+        <xsl:text>]]</xsl:text>
+        <xsl:text>
+</xsl:text>
+    </xsl:template>
+    
+    <xsl:function name="pg:dup">
+        <xsl:param name="input"/>
+        <xsl:param name="count"/>
+        <xsl:sequence select="string-join(for $l in 1 to $count return $input, '')"/>
+    </xsl:function>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 </xsl:transform>