commit:     a104fe1378cebfb50494565fb0d2cb589a682831
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 30 19:04:05 2024 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Oct 31 18:56:03 2024 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=a104fe13

Support caption attribute for pre, codesample and table

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 devbook.rnc   | 12 ++++++++++--
 devbook.rng   |  9 +++++++++
 devbook.xsl   | 13 ++++++++++++-
 devmanual.css |  4 ++++
 4 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/devbook.rnc b/devbook.rnc
index 22f7c09..06b5f5b 100644
--- a/devbook.rnc
+++ b/devbook.rnc
@@ -56,11 +56,15 @@ contentsTree = element contentsTree {
 
 p = element p { inline }
 
-pre = element pre { text }
+pre = element pre {
+  attribute caption { text }?,
+  text
+}
 
 codesample = element codesample {
   attribute lang { "c" | "ebuild" | "make" | "m4" | "sgml" },
   attribute numbering { "lines" }?,
+  attribute caption { text }?,
   text
 }
 
@@ -75,7 +79,11 @@ figure = element figure {
   attribute caption { text }?
 }
 
-table = element table { tr+ }
+table = element table {
+  attribute caption { text }?,
+  tr+
+}
+
 tr = element tr { (th | ti)+ }
 
 th = element th {

diff --git a/devbook.rng b/devbook.rng
index 3963ab1..c482fd0 100644
--- a/devbook.rng
+++ b/devbook.rng
@@ -191,6 +191,9 @@
   </define>
   <define name="pre">
     <element name="pre">
+      <optional>
+        <attribute name="caption"/>
+      </optional>
       <text/>
     </element>
   </define>
@@ -210,6 +213,9 @@
           <value>lines</value>
         </attribute>
       </optional>
+      <optional>
+        <attribute name="caption"/>
+      </optional>
       <text/>
     </element>
   </define>
@@ -246,6 +252,9 @@
   </define>
   <define name="table">
     <element name="table">
+      <optional>
+        <attribute name="caption"/>
+      </optional>
       <oneOrMore>
         <ref name="tr"/>
       </oneOrMore>

diff --git a/devbook.xsl b/devbook.xsl
index fb7ae25..87aa0e8 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -60,13 +60,21 @@
 </xsl:template>
 
 <xsl:template match="pre">
+  <xsl:if test="@caption">
+    <p class="caption"><xsl:value-of select="@caption"/></p>
+  </xsl:if>
   <pre><xsl:apply-templates/></pre>
 </xsl:template>
 
 <!-- Tables -->
 <!-- From the Gentoo GuideXML Stylesheet -->
 <xsl:template match="table">
-  <table class="table"><xsl:apply-templates/></table>
+  <table class="table">
+    <xsl:if test="@caption">
+      <caption><xsl:value-of select="@caption"/></caption>
+    </xsl:if>
+    <xsl:apply-templates/>
+  </table>
 </xsl:template>
 
 <xsl:template match="tr">
@@ -122,6 +130,9 @@
   <xsl:variable name="ctype"><xsl:if test="@lang = 
'ebuild'">Constant</xsl:if></xsl:variable>
   <xsl:variable name="numbering" select="@numbering"/>
   <xsl:variable name="lang" select="@lang"/>
+  <xsl:if test="@caption">
+    <p class="caption"><xsl:value-of select="@caption"/></p>
+  </xsl:if>
   <pre><span class="{$ctype}">
     <xsl:for-each select="str:tokenize_plasmaroo(., $newline)">
       <xsl:choose>

diff --git a/devmanual.css b/devmanual.css
index 83f6b14..d636585 100644
--- a/devmanual.css
+++ b/devmanual.css
@@ -13,6 +13,10 @@ dd {
     margin-left: 2em;
 }
 
+caption, p.caption {
+    font-weight: bold;
+}
+
 div.figure, div.figure p {
     text-align: center;
     font-weight: bold;

Reply via email to