[telepathy-doc/master] Working <embeddb> tag for embedding Docbook inside HTML (that is embedded inside Docbook)

Davyd Madeley davyd at madeley.id.au
Thu Apr 2 00:16:52 PDT 2009


---
 docs/book/insert-examples.py  |    4 ++--
 docs/book/xslt/db2html.xsl.in |   17 ++++++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/docs/book/insert-examples.py b/docs/book/insert-examples.py
index bb07006..c4ded7d 100755
--- a/docs/book/insert-examples.py
+++ b/docs/book/insert-examples.py
@@ -140,10 +140,10 @@ for nicename in included_files:
 
 	for id in included_files[nicename]:
 		sre = re.compile ('(\\s)begin (%s)(\\s|$)' % re.escape (id), re.IGNORECASE)
-		contents = sre.sub(r'\1Begin <xref linkend="\2"/>\3', contents)
+		contents = sre.sub(r'\1Begin <embeddb><xref linkend="\2"/></embeddb>\3', contents)
 
 		sre = re.compile ('(\\s)end (%s)(\\s|$)' % re.escape (id), re.IGNORECASE)
-		contents = sre.sub(r'\1End <xref linkend="\2"/>\3', contents)
+		contents = sre.sub(r'\1End <embeddb><xref linkend="\2"/></embeddb>\3', contents)
 
 	pl = etree.SubElement (s, 'programlisting')
 	pl.append (etree.XML (contents))
diff --git a/docs/book/xslt/db2html.xsl.in b/docs/book/xslt/db2html.xsl.in
index 0036e8f..553473d 100644
--- a/docs/book/xslt/db2html.xsl.in
+++ b/docs/book/xslt/db2html.xsl.in
@@ -23,9 +23,20 @@
        This allows us to embed XHTML directly into the output, e.g. from
        a syntax highlighter -->
   <xsl:template match="embedhtml">
-   <xsl:copy-of select="./*">
-    <xsl:call-template name="db2html.xref"/>
-   </xsl:copy-of>
+   <xsl:apply-templates select="node()" mode="embedhtml"/>
+  </xsl:template>
+
+  <!-- matches <embeddb> inside <embedhtml> to switch back to docbook -->
+  <xsl:template match="embeddb" mode="embedhtml">
+   <xsl:apply-templates select="node()"/>
+  </xsl:template>
+
+  <!-- recursive copy in embedhtml mode, see
+       http://www.xmlplease.com/xsltidentity -->
+  <xsl:template match="@*|node()" mode="embedhtml">
+   <xsl:copy>
+    <xsl:apply-templates select="@*|node()" mode="embedhtml"/>
+   </xsl:copy>
   </xsl:template>
 
   <!-- the header to put at the top of every page -->
-- 
1.5.6.5



More information about the telepathy-commits mailing list