[gnome-doc-utils/mallard] [mallard] Work on terms and tree lists



commit b077d566a813b0ab58b9b00af4dd201e3feaa7c8
Author: Shaun McCance <shaunm gnome org>
Date:   Sun May 24 21:46:43 2009 -0500

    [mallard] Work on terms and tree lists
---
 doc/mallard/C/mal_block_terms.xml   |   86 ++++++++++++++++++++++++++++
 doc/mallard/C/mal_block_tree.xml    |   58 +++++++++++++++++++
 xslt/mallard/html/mal2html-css.xsl  |    4 +-
 xslt/mallard/html/mal2html-list.xsl |  107 +++++++++++++++++++++++++++--------
 4 files changed, 229 insertions(+), 26 deletions(-)

diff --git a/doc/mallard/C/mal_block_terms.xml b/doc/mallard/C/mal_block_terms.xml
index 11dca03..8a01dda 100644
--- a/doc/mallard/C/mal_block_terms.xml
+++ b/doc/mallard/C/mal_block_terms.xml
@@ -71,6 +71,82 @@ mal_block_terms = element terms {
 <!-- BEGIN examples -->
 <section id="examples">
   <title>Examples</title>
+
+  <p>Create a simple definition list with a title:</p>
+
+  <example>
+    <code><![CDATA[
+<terms>
+  <title>Selected Basic Block Elements</title>
+  <item>
+    <title><code>code</code></title>
+    <p>Mark up a block of code or the contents of a file.</p>
+  </item>
+  <item>
+    <title><code>example</code></title>
+    <p>Mark up a group of block elements as being part of a single example.</p>
+  </item>
+  <item>
+    <title><code>screen</code></title>
+    <p>Mark up a textual user interface or an interactive shell session.</p>
+  </item>
+</terms>]]></code>
+    <terms>
+      <title>Selected Basic Block Elements</title>
+      <item>
+        <title><code>code</code></title>
+        <p>Mark up a block of code or the contents of a file.</p>
+      </item>
+      <item>
+        <title><code>example</code></title>
+        <p>Mark up a group of block elements as being part of a single example.</p>
+      </item>
+      <item>
+        <title><code>screen</code></title>
+        <p>Mark up a textual user interface or an interactive shell session.</p>
+      </item>
+    </terms>
+  </example>
+
+  <p>Create a definition list with multiple terms per entry:</p>
+
+  <example>
+    <code><![CDATA[
+<terms>
+  <item>
+    <title><code>comment</code></title>
+    <title><code>quote</code></title>
+    <p>Formal elements which allow a <code>cite</code> element.</p>
+  </item>
+  <item>
+    <title><code>figure</code></title>
+    <title><code>listing</code></title>
+    <title><code>synopsis</code></title>
+    <p>Formal elements which allow a <code>desc</code> element.</p>
+  </item>
+  <item>
+    <title><code>note</code></title>
+    <p>Formal elements which only allow a <code>title</code> element.</p>
+  </item>
+</terms>]]></code>
+    <terms>
+      <item>
+        <title><code>comment</code></title>
+        <title><code>quote</code></title>
+        <p>Formal elements which allow a <code>cite</code> element.</p>
+      </item>
+      <item>
+        <title><code>figure</code></title>
+        <title><code>listing</code></title>
+        <title><code>synopsis</code></title>
+        <p>Formal elements which allow a <code>desc</code> element.</p>
+      </item>
+      <item>
+        <title><code>note</code></title>
+        <p>Formal elements which only allow a <code>title</code> element.</p>
+      </item>
+    </terms>
+  </example>
 </section>
 <!-- END examples -->
 
@@ -86,6 +162,16 @@ mal_block_terms = element terms {
 <!-- BEGIN comparison -->
 <section id="comparison">
   <title>Comparison to Other Formats</title>
+  
+  <p>The <code>terms</code> element is similar to
+  <code href="http://www.docbook.org/tdg/en/html/variablelist.html";>variablelist</code>
+  element in DocBook.  Like DocBook (and unlike HTML), Mallard groups terms with their
+  corresponding entries.  In DocBook, the entry must be wrapped with a
+  <code href="http://www.docbook.org/tdg/en/html/listitem.html";>listitem</code>
+  element inside the
+  <code href="http://www.docbook.org/tdg/en/html/varlistentry.html";>varlistentry</code>
+  element.  In Mallard, the entry is simply all of the block content except the
+  <code xref="mal_block_title">title</code> elements.</p>
 </section>
 <!-- END comparison -->
 
diff --git a/doc/mallard/C/mal_block_tree.xml b/doc/mallard/C/mal_block_tree.xml
index cacbdc1..440033a 100644
--- a/doc/mallard/C/mal_block_tree.xml
+++ b/doc/mallard/C/mal_block_tree.xml
@@ -25,4 +25,62 @@ mal_tree_item = element item {
 }
 </code></synopsis>
 
+
+<!-- BEGIN examples -->
+<section id="examples">
+  <title>Examples</title>
+
+  <p>Use a tree to outline a class heirarchy inside a
+  <code xref="mal_block_synopsis">>synopsis</code> element:</p>
+
+  <example>
+    <code><![CDATA[
+<synopsis>
+  <tree>
+    <item>
+      <code>GtkBin</code>
+      <item>
+        <code>GtkButton</code>
+        <item><code>GtkToggleButton</code></item>
+        <item><code>GtkColorButton</code></item>
+        <item><code>GtkFontButton</code></item>
+        <item><code>GtkLinkButton</code></item>
+        <item><code>GtkOptionMenu</code></item>
+        <item><code>GtkScaleButton</code></item>
+      </item>
+    </item>
+  </tree>
+</synopsis>]]></code>
+    <synopsis>
+      <tree>
+        <item>
+          <code>GtkBin</code>
+          <item>
+            <code>GtkButton</code>
+            <item><code>GtkToggleButton</code></item>
+            <item><code>GtkColorButton</code></item>
+            <item><code>GtkFontButton</code></item>
+            <item><code>GtkLinkButton</code></item>
+            <item><code>GtkOptionMenu</code></item>
+            <item><code>GtkScaleButton</code></item>
+          </item>
+        </item>
+      </tree>
+    </synopsis>
+  </example>
+
+    <tree style="lines">
+      <item>
+        one
+        <item>do</item>
+        <item>re</item>
+        <item>mi</item>
+      </item>
+      <item>
+        two
+      </item>
+    </tree>
+</section>
+<!-- END examples -->
+
 </page>
diff --git a/xslt/mallard/html/mal2html-css.xsl b/xslt/mallard/html/mal2html-css.xsl
index e62ae72..5ae2315 100644
--- a/xslt/mallard/html/mal2html-css.xsl
+++ b/xslt/mallard/html/mal2html-css.xsl
@@ -95,8 +95,8 @@ body {
   padding: 12px;
   min-height: 100%;
 }
-ul, ol, dl { margin: 0; }
-div, pre, p, li { margin: 1em 0 0 0; padding: 0; }
+ul, ol, dl, dd { margin: 0; }
+div, pre, p, li, dt { margin: 1em 0 0 0; padding: 0; }
 .first-child { margin-top: 0; }
 a {
   text-decoration: none;
diff --git a/xslt/mallard/html/mal2html-list.xsl b/xslt/mallard/html/mal2html-list.xsl
index 0871091..f5b7c25 100644
--- a/xslt/mallard/html/mal2html-list.xsl
+++ b/xslt/mallard/html/mal2html-list.xsl
@@ -36,11 +36,13 @@ REMARK: Describe this template
 -->
 <xsl:template name="mal2html.list.css">
 <xsl:text>
+div.list-contents { margin: 0; padding: 0; }
 div.title-list { margin-bottom: 0.5em; }
 ol.list, ul.list { margin: 0; padding: 0; }
 li.item-list { margin-left: 1.44em; }
 
-div.steps {
+div.steps-contents {
+  margin: 0;
   padding: 0.5em 1em 0.5em 1em;
   border-top: solid 2px;
   border-bottom: solid 2px;
@@ -49,15 +51,21 @@ div.steps {
   background-color: </xsl:text>
     <xsl:value-of select="$theme.color.yellow_background"/><xsl:text>;
 }
-div.steps div.steps {
+div.steps-contents div.steps-contents {
   padding: 0;
   border: none;
   background-color: none;
 }
-div.title-steps { margin-bottom: 0.5em; }
 ol.steps, ul.steps { margin: 0; padding: 0; }
 li.item-steps { margin-left: 1.44em; }
 
+div.terms-contents { margin: 0; }
+dt.item-next { margin-top: 0; }
+dd.item-terms {
+  margin-top: 0.2em;
+  margin-left: 1.44em;
+}
+
 ul.tree {
   margin: 0; padding: 0;
   list-style-type: none;
@@ -100,17 +108,19 @@ div.tree-lines ul.tree ul.tree ul.tree {
       </xsl:if>
     </xsl:attribute>
     <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
-    <xsl:element name="{$el}" namespace="{$mal2html.namespace}">
-      <xsl:attribute name="class">
-        <xsl:text>list</xsl:text>
-      </xsl:attribute>
-      <xsl:if test="@type">
-        <xsl:attribute name="style">
-          <xsl:value-of select="concat('list-style-type:', @type)"/>
+    <div class="list-contents">
+      <xsl:element name="{$el}" namespace="{$mal2html.namespace}">
+        <xsl:attribute name="class">
+          <xsl:text>list</xsl:text>
         </xsl:attribute>
-      </xsl:if>
-      <xsl:apply-templates mode="mal2html.list.list.mode" select="mal:item"/>
-    </xsl:element>
+        <xsl:if test="@type">
+          <xsl:attribute name="style">
+            <xsl:value-of select="concat('list-style-type:', @type)"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates mode="mal2html.list.list.mode" select="mal:item"/>
+      </xsl:element>
+    </div>
   </div>
 </xsl:template>
 
@@ -124,9 +134,9 @@ div.tree-lines ul.tree ul.tree ul.tree {
       </xsl:if>
     </xsl:attribute>
     <xsl:for-each
-        select="mal:*[
-                ($mal2html.editor_mode or not(self::mal:comment)
-                or processing-instruction('mal2html.show_comment'))]">
+     select="mal:*[
+             ($mal2html.editor_mode or not(self::mal:comment)
+             or processing-instruction('mal2html.show_comment'))]">
       <xsl:apply-templates mode="mal2html.block.mode" select=".">
         <xsl:with-param name="first_child" select="position() = 1"/>
       </xsl:apply-templates>
@@ -145,13 +155,15 @@ div.tree-lines ul.tree ul.tree ul.tree {
       </xsl:if>
     </xsl:attribute>
     <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
-    <ol class="steps">
-      <xsl:apply-templates mode="mal2html.list.steps.mode" select="mal:item"/>
-    </ol>
+    <div class="steps-contents">
+      <ol class="steps">
+        <xsl:apply-templates mode="mal2html.list.steps.mode" select="mal:item"/>
+      </ol>
+    </div>
   </div>
 </xsl:template>
 
-<!-- = list/item = -->
+<!-- = steps/item = -->
 <xsl:template mode="mal2html.list.steps.mode" match="mal:item">
   <li>
     <xsl:attribute name="class">
@@ -161,9 +173,9 @@ div.tree-lines ul.tree ul.tree ul.tree {
       </xsl:if>
     </xsl:attribute>
     <xsl:for-each
-        select="mal:*[
-                ($mal2html.editor_mode or not(self::mal:comment)
-                or processing-instruction('mal2html.show_comment'))]">
+     select="mal:*[
+             ($mal2html.editor_mode or not(self::mal:comment)
+             or processing-instruction('mal2html.show_comment'))]">
       <xsl:apply-templates mode="mal2html.block.mode" select=".">
         <xsl:with-param name="first_child" select="position() = 1"/>
       </xsl:apply-templates>
@@ -171,6 +183,53 @@ div.tree-lines ul.tree ul.tree ul.tree {
   </li>
 </xsl:template>
 
+<!-- = terms = -->
+<xsl:template mode="mal2html.block.mode" match="mal:terms">
+  <xsl:param name="first_child" select="not(preceding-sibling::*)"/>
+  <div>
+    <xsl:attribute name="class">
+      <xsl:text>terms</xsl:text>
+      <xsl:if test="$first_child">
+        <xsl:text> first-child</xsl:text>
+      </xsl:if>
+    </xsl:attribute>
+    <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
+    <div class="terms-contents">
+      <dl class="terms">
+        <xsl:apply-templates mode="mal2html.list.terms.mode" select="mal:item"/>
+      </dl>
+    </div>
+  </div>
+</xsl:template>
+
+<!-- = list/item = -->
+<xsl:template mode="mal2html.list.terms.mode" match="mal:item">
+  <xsl:for-each select="mal:title">
+    <dt>
+      <xsl:attribute name="class">
+        <xsl:text>item-terms</xsl:text>
+        <xsl:if test="not(../preceding-sibling::mal:item)">
+          <xsl:text> first-child</xsl:text>
+        </xsl:if>
+        <xsl:if test="preceding-sibling::mal:title">
+          <xsl:text> item-next</xsl:text>
+        </xsl:if>
+      </xsl:attribute>
+      <xsl:apply-templates mode="mal2html.inline.mode"/>
+    </dt>
+  </xsl:for-each>
+  <dd class="item-terms">
+    <xsl:for-each
+     select="mal:*[not(self::mal:title)
+             and ($mal2html.editor_mode or not(self::mal:comment)
+             or processing-instruction('mal2html.show_comment'))]">
+      <xsl:apply-templates mode="mal2html.block.mode" select=".">
+        <xsl:with-param name="first_child" select="position() = 1"/>
+      </xsl:apply-templates>
+    </xsl:for-each>
+  </dd>
+</xsl:template>
+
 <!-- = tree = -->
 <xsl:template mode="mal2html.block.mode" match="mal:tree">
   <xsl:param name="first_child" select="not(preceding-sibling::*)"/>
@@ -210,7 +269,7 @@ div.tree-lines ul.tree ul.tree ul.tree {
         </xsl:choose>
       </xsl:if>
       <xsl:apply-templates mode="mal2html.inline.mode"
-                           select="*[not(self::mal:item)]"/>
+                           select="node()[not(self::mal:item)]"/>
     </div>
     <xsl:if test="mal:item">
       <ul class="tree">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]