[vala: 2/4] manual: Switch to using DocBook from wiki.gnome.org as source



commit b8c5ca22b4ad931f9b2ac459768831168f01dda9
Author: Alistair Thomas <astavale yahoo co uk>
Date:   Thu Jan 19 20:57:20 2017 +0000

    manual: Switch to using DocBook from wiki.gnome.org as source
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779090

 configure.ac           |    1 +
 doc/manual/.gitignore  |    4 +-
 doc/manual/Makefile.am |  103 ++++++-------
 doc/manual/common.xsl  |   42 +++++
 doc/manual/default.css |   72 ++++++++--
 doc/manual/devhelp.xsl |   54 +++++--
 doc/manual/xhtml.xsl   |  400 +++++++++++++++++++++++++++++++++++-------------
 7 files changed, 491 insertions(+), 185 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5e13182..2c90ba4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_LN_S
 AC_PROG_INSTALL
+AC_PROG_MKDIR_P
 
 LT_PREREQ([2.2.6])
 LT_INIT([disable-static])
diff --git a/doc/manual/.gitignore b/doc/manual/.gitignore
index cccbd85..34a65b6 100644
--- a/doc/manual/.gitignore
+++ b/doc/manual/.gitignore
@@ -1,2 +1,2 @@
-*.html
-vala*.devhelp2
+html/
+devhelp/
diff --git a/doc/manual/Makefile.am b/doc/manual/Makefile.am
index c980cf6..ffa87f9 100644
--- a/doc/manual/Makefile.am
+++ b/doc/manual/Makefile.am
@@ -1,69 +1,66 @@
 NULL =
 
-book_name=vala@PACKAGE_SUFFIX@
+BOOK_NAME = vala@PACKAGE_SUFFIX@
 
-bookdir=$(datadir)/devhelp/books/$(book_name)
-
-chapter_data = \
-       overview.html \
-       types.html \
-       expressions.html \
-       statements.html \
-       namespaces.html \
-       methods.html \
-       classes.html \
-       structs.html \
-       interfaces.html \
-       enums.html \
-       delegates.html \
-       exceptions.html \
-       attributes.html \
-       $(NULL)
-
-built_data = \
-       index.html \
-       $(chapter_data) \
-       $(book_name).devhelp2 \
-       $(NULL)
+bookdir = $(datadir)/devhelp/books/$(BOOK_NAME)
 
 if HAVE_XSLTPROC
-book_DATA = \
-       $(built_data) \
-       default.css \
+nobase_book_DATA = \
+       devhelp/* \
        $(NULL)
 endif
 
-index.html: $(book_sources) xhtml.xsl
-       $(AM_V_GEN)$(XSLTPROC) --xinclude $(srcdir)/xhtml.xsl $(srcdir)/index.xml > index.html
-
-$(chapter_data): index.html
+$(builddir)/devhelp/*: devhelp
+devhelp: manual.xml devhelp.xsl xhtml.xsl
+       @$(MKDIR_P) $@
+       $(AM_V_GEN)$(XSLTPROC) \
+               --xinclude $(srcdir)/devhelp.xsl \
+               $(srcdir)/manual.xml \
+               > $(builddir)/devhelp/$(BOOK_NAME).devhelp2
+       @$(XSLTPROC) \
+               --xinclude \
+               --stringparam outdir $@ \
+               --output $@/index.html \
+               $(srcdir)/xhtml.xsl \
+               $(srcdir)/manual.xml
+       @cp $(srcdir)/default.css $@
 
-$(book_name).devhelp2: $(book_sources) devhelp.xsl
-       $(AM_V_GEN)$(XSLTPROC) --xinclude $(srcdir)/devhelp.xsl $(srcdir)/index.xml > $(book_name).devhelp2
+html: manual.xml xhtml.xsl
+       @$(MKDIR_P) $@
+       $(AM_V_GEN)$(XSLTPROC) \
+               --xinclude \
+               --stringparam outdir $@ \
+               --output $@/index.html \
+               $(srcdir)/xhtml.xsl \
+               $(srcdir)/manual.xml
+       @cp $(srcdir)/default.css $@
 
-book_sources = \
-       index.xml \
-       overview.xml \
-       types.xml \
-       expressions.xml \
-       statements.xml \
-       namespaces.xml \
-       methods.xml \
-       classes.xml \
-       structs.xml \
-       interfaces.xml \
-       enums.xml \
-       delegates.xml \
-       exceptions.xml \
-       attributes.xml \
-       $(NULL)
-
-MOSTLYCLEANFILES = $(built_data)
+mostlyclean-local:
+       rm -rf devhelp
+       rm -rf html
 
 EXTRA_DIST = \
-       $(book_sources) \
+       common.xsl \
        default.css \
-       xhtml.xsl \
        devhelp.xsl \
+       manual.xml \
+       xhtml.xsl \
        $(NULL)
 
+MANUAL_DOCBOOK_URL=https://wiki.gnome.org/Projects/Vala/Manual/Export?action=format\&mimetype=text/docbook
+
+$(srcdir)/manual.xml:
+       @echo "Generating $@ from $(MANUAL_DOCBOOK_URL)"
+       @curl --silent $(MANUAL_DOCBOOK_URL) | \
+               sed -e 's/<articleinfo>.*<\/articleinfo>//g' | \
+               sed -e 's/<section>/\n\n<section>/g' | \
+               sed -e 's/<\/section>/\n<\/section>/g' | \
+               sed -e 's/<title>/\n<title>/g' | \
+               sed -e 's/<para>/\n<para>/g' \
+               > $@
+
+update-manual-from-wiki:
+       @rm $(srcdir)/manual.xml
+       $(MAKE) $(AM_MAKEFLAGS) manual.xml
+       $(MAKE) $(AM_MAKEFLAGS)
+
diff --git a/doc/manual/common.xsl b/doc/manual/common.xsl
new file mode 100644
index 0000000..68cf4bf
--- /dev/null
+++ b/doc/manual/common.xsl
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+  version="1.0"
+  xmlns:str="http://exslt.org/strings";
+  xmlns:exsl="http://exslt.org/common";
+  extension-element-prefixes="exsl"
+  exclude-result-prefixes="str"
+>
+
+  <xsl:template name="normalizepath">
+    <xsl:param name="title"/>
+    <xsl:variable name="space-to-underscore" select="str:replace($title, ' ', '_')"/>
+    <xsl:variable name="open-parens-to-underscore" select="str:replace($space-to-underscore, '(', '_')"/>
+    <xsl:value-of select="str:replace($open-parens-to-underscore, ')', '_')"/>
+  </xsl:template>
+
+  <xsl:template name="linkto">
+    <xsl:param name="page"/>
+    <xsl:param name="subpage"/>
+    <xsl:param name="title"/>
+    <xsl:variable name="path">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="$page"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="fragment">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="$subpage"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:choose>
+      <xsl:when test="$fragment=''">
+      <a href="{$path}.html"><xsl:value-of select="$title"/></a>
+      </xsl:when>
+      <xsl:otherwise>
+      <a href="{$path}.html#{$fragment}"><xsl:value-of select="$title"/></a>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/doc/manual/default.css b/doc/manual/default.css
index 9294f26..ee76427 100644
--- a/doc/manual/default.css
+++ b/doc/manual/default.css
@@ -1,13 +1,22 @@
 body {
        background-color: white;
-       font-family: sans-serif;
+       font-family: cantarell, sans-serif;
+       text-align: justify;
        margin-top: 2.8em;
+       max-width: 35em;
 }
 
 h1, h2, h3, h4 {
        color: #005a9c;
+       margin: 1.5em 0 0 0;
 }
 
+h3 { border-top: solid 0.5em #eee; }
+
+h4 { border-top: solid 0.2em #eee; }
+
+p { margin: 0 0 1em 0; }
+
 a:link, a:visited, a:hover, a:active {
        color: #005a9c;
        text-decoration: none;
@@ -15,7 +24,9 @@ a:link, a:visited, a:hover, a:active {
 
 .toc {
        font-weight: bold;
-       font-size: larger;
+       font-size: 120%;
+       line-height: 1.8;
+       max-width: 19em;
 }
 
 .toc li {
@@ -23,13 +34,22 @@ a:link, a:visited, a:hover, a:active {
 }
 
 .toc li li {
-       font-size: smaller;
+       font-size: 80%;
+}
+
+.toc a {
+       display:block;
+       border-radius: 0.4em;
+       padding-left: 0.4em;
 }
 
-h3 a {
+.toc a:hover, .toc a:focus {
+       background-color: #ddd;
+}
+
+h3 {
        /* ensure anchors don't vanish below the fixed header */
-       position: relative;
-       top: -2.8em;
+       padding-top: 1.4em;
 }
 
 .header {
@@ -60,17 +80,49 @@ div.note p, div.note h4 {
 pre {
        background-color: #eee;
        border: 1px solid black;
+       border-radius: 4px;
        padding: .5em 1em;
-       margin: 0 2em 1em 2em;
+       margin: 0 0 1em 0;
 }
 
-blockquote {
+.o-box { padding: 1.2em;
+       margin: 0 0 1em 0;
+       line-height: 1.5;
+}
+.c-program { background-color: #f5f5f5;
+       border: 2px solid #ca8;
+       border-radius: 4px;
+       font-family: monospace;
+       white-space: pre-wrap;
+}
+.c-program-type { color: #533; }
+.c-program-token { color: #000;
+       font-weight: bold;
+}
+.c-program-methodname { color: #520;
        font-style: italic;
-       white-space: pre;
+}
+.c-program-phrase { color: #161; }
+
+.c-informaltable { border: solid 2px #ccc;
+       border-radius: 4px;
+}
+.c-informaltable td { border-bottom: solid 1px #ccc;
+       border-right: solid 1px #ccc;
+}
+.c-informaltable td:last-child { border-right: none; }
+.c-informaltable tr:last-child td { border-bottom: none; }
+.c-informaltable tr:nth-child(even) { background-color: #f5f5f5; }
+
+.c-rules { border: solid 2px #729fcf;
+       border-radius: 4px;
+       background-color: #f5f5f5;
+       white-space: pre-wrap;
 }
 
 blockquote span.literal {
        font-family: monospace;
-       font-style: normal;
        font-weight: bold;
+       font-size: 110%;
+       padding-right: 0.5em;
 }
diff --git a/doc/manual/devhelp.xsl b/doc/manual/devhelp.xsl
index 735ff18..3a1db14 100644
--- a/doc/manual/devhelp.xsl
+++ b/doc/manual/devhelp.xsl
@@ -1,18 +1,42 @@
 <?xml version="1.0"?>
-<xsl:stylesheet xmlns="http://www.devhelp.net/book"; xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.1">
-       <xsl:output method="xml" indent="yes"/>
-       <xsl:template match="/">
-               <book title="{//title/text()}" link="index.html" author="" name="vala" version="2">
-                       <chapters>
-                               <xsl:for-each select="//body/section">
-                                       <sub name="{h/text()}" link="{@id}.html">
-                                               <xsl:for-each select="section">
-                                                       <sub name="{h/text()}" link="{../@id}.html#{@id}"/>
-                                               </xsl:for-each>
-                                       </sub>
-                               </xsl:for-each>
-                       </chapters>
-               </book>
-       </xsl:template>
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+  version="1.1"
+  xmlns="http://www.devhelp.net/book";
+  >
+
+  <xsl:import href="common.xsl"/>
+
+  <xsl:output
+    method="xml"
+    indent="yes"
+  />
+
+  <xsl:template match="/">
+    <book title="{/article/section/title/text()}" link="index.html" author="" name="vala" version="2">
+      <chapters>
+        <xsl:apply-templates select="/article/section/section"/>
+      </chapters>
+    </book>
+  </xsl:template>
+
+  <xsl:template match="/article/section/section">
+    <xsl:variable name="path">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="title"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <sub name="{title/text()}" link="{$path}.html">
+      <xsl:for-each select="section">
+        <xsl:variable name="fragment">
+          <xsl:call-template name="normalizepath">
+            <xsl:with-param name="title" select="title"/>
+          </xsl:call-template>
+        </xsl:variable>
+        <sub name="{title/text()}" link="{$path}.html#{$fragment}"/>
+      </xsl:for-each>
+    </sub>
+  </xsl:template>
+
 </xsl:stylesheet>
 
diff --git a/doc/manual/xhtml.xsl b/doc/manual/xhtml.xsl
index 607fbac..43420bc 100644
--- a/doc/manual/xhtml.xsl
+++ b/doc/manual/xhtml.xsl
@@ -1,107 +1,297 @@
 <?xml version="1.0"?>
-<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"; xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.1">
-       <xsl:output method="xml" indent="yes" 
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; doctype-public="-//W3C//DTD XHTML 1.0 
Strict//EN"/>
-       <xsl:strip-space elements="blockquote/l"/>
-       <xsl:template match="/">
-               <xsl:apply-templates select="html"/>
-       </xsl:template>
-       <xsl:template match="html">
-               <html><xsl:apply-templates select="head|body"/></html>
-       </xsl:template>
-       <xsl:template match="head">
-               <head>
-                       <xsl:apply-templates select="title"/>
-                       <link rel="stylesheet" type="text/css" href="default.css"/>
-               </head>
-       </xsl:template>
-       <xsl:template match="title">
-               <title><xsl:value-of select="."/></title>
-       </xsl:template>
-       <xsl:template match="body">
-               <body>
-                       <div class="header">
-                               <a href="index.html"><xsl:value-of select="//title/text()"/></a>
-                       </div>
-                       <xsl:apply-templates select="h|p|section"/>
-                       <ul class="toc">
-                               <xsl:for-each select="section">
-                                       <li>
-                                               <a href="{@id}.html"><xsl:value-of select="h/text()"/></a>
-                                               <xsl:if test="count(section) > 0">
-                                                       <ul>
-                                                               <xsl:for-each select="section">
-                                                                       <li><a 
href="{../@id}.html#{@id}"><xsl:value-of select="h/text()"/></a></li>
-                                                               </xsl:for-each>
-                                                       </ul>
-                                               </xsl:if>
-                                       </li>
-                               </xsl:for-each>
-                       </ul>
-               </body>
-       </xsl:template>
-       <xsl:template match="body/h">
-               <h1><xsl:value-of select="text()"/></h1>
-       </xsl:template>
-       <xsl:template match="body/section">
-               <xsl:document href="{@id}.html" method="xml" indent="yes">
-                       <html>
-                               <head>
-                                       <title><xsl:value-of select="h/text()"/> - <xsl:value-of 
select="//title/text()"/></title>
-                                       <link rel="stylesheet" type="text/css" href="default.css"/>
-                               </head>
-                               <body>
-                                       <div class="header">
-                                               <a href="index.html"><xsl:value-of 
select="//title/text()"/></a>
-                                       </div>
-                                       <xsl:apply-templates 
select="h|p|section|div|blockcode|blockquote|ol|ul"/>
-                               </body>
-                       </html>
-               </xsl:document>
-       </xsl:template>
-       <xsl:template match="body/section/h">
-               <h2><xsl:value-of select="text()"/></h2>
-       </xsl:template>
-       <xsl:template match="body/section/section">
-               <xsl:apply-templates select="h|p|div|blockcode|blockquote|section|ol|ul"/>
-       </xsl:template>
-       <xsl:template match="body/section/section/h">
-               <h3><xsl:value-of select="text()"/><a id="{../@id}"><xsl:text> </xsl:text></a></h3>
-       </xsl:template>
-       <xsl:template match="body/section/section/section">
-               <xsl:apply-templates select="h|p|div|blockcode|blockquote|section|ol|ul"/>
-       </xsl:template>
-       <xsl:template match="body/section/section/section/h">
-               <h4><xsl:value-of select="text()"/><a id="{../@id}"><xsl:text> </xsl:text></a></h4>
-       </xsl:template>
-       <xsl:template match="div[@role='note']">
-               <div class="note"><xsl:apply-templates select="h|p|blockcode|blockquote"/></div>
-       </xsl:template>
-       <xsl:template match="div/h">
-               <h4><xsl:value-of select="text()"/></h4>
-       </xsl:template>
-       <xsl:template match="p">
-               <p><xsl:apply-templates select="text()|code"/></p>
-       </xsl:template>
-       <xsl:template match="code">
-               <code><xsl:value-of select="text()"/></code>
-       </xsl:template>
-       <xsl:template match="blockcode">
-               <pre><xsl:value-of select="text()"/></pre>
-       </xsl:template>
-       <xsl:template match="blockquote">
-               <blockquote><xsl:apply-templates select="text()|l"/></blockquote>
-       </xsl:template>
-       <xsl:template match="blockquote/l">
-               <span class="literal"><xsl:value-of select="text()"/></span>
-       </xsl:template>
-       <xsl:template match="ol">
-               <ol><xsl:apply-templates select="item"/></ol>
-       </xsl:template>
-       <xsl:template match="ul">
-               <ul><xsl:apply-templates select="item"/></ul>
-       </xsl:template>
-       <xsl:template match="ol/item|ul/item">
-               <li><xsl:value-of select="text()"/></li>
-       </xsl:template>
-</xsl:stylesheet>
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+  version="1.0"
+  xmlns:str="http://exslt.org/strings";
+  xmlns:exsl="http://exslt.org/common";
+  extension-element-prefixes="exsl"
+  exclude-result-prefixes="str"
+>
+
+  <xsl:import href="common.xsl"/>
+
+  <xsl:output
+    method="html"
+    indent="yes"
+    omit-xml-declaration="yes"
+    encoding="UTF-8"
+    media-type="text/html"
+  />
+
+  <xsl:template match="/">
+    <xsl:call-template name="html5-doctype"/>
+    <html><xsl:call-template name="whitespace-newline"/>
+    <head><xsl:call-template name="whitespace-newline"/>
+    <xsl:apply-templates select="article/section/title[1]" mode="html-head"/>
+    </head><xsl:call-template name="whitespace-newline"/>
+    <body><xsl:call-template name="whitespace-newline"/>
+    <xsl:apply-templates select="article" mode="toc"/>
+    </body><xsl:call-template name="whitespace-newline"/>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="article/section/section">
+    <xsl:variable name="path">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="title"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <exsl:document
+      href="{$path}.html"
+      method="html"
+      indent="yes"
+      omit-xml-declaration="yes"
+    >
+      <xsl:call-template name="html5-doctype"/>
+      <html>
+        <head>
+        <xsl:apply-templates select="title" mode="html-head"/>
+        </head>
+        <body>
+          <div class="header">
+            <a href="index.html"><xsl:value-of select="/article/section/title"/></a>
+          </div>
+          <xsl:apply-templates select="title"/>
+          <xsl:if test="count(section) > 0">
+            <ul class="page_toc">
+              <xsl:for-each select="section">
+                <li>
+                  <xsl:call-template name="linkto">
+                    <xsl:with-param name="page" select="../title"/>
+                    <xsl:with-param name="subpage" select="title"/>
+                    <xsl:with-param name="title" select="title"/>
+                  </xsl:call-template>
+                </li>
+              </xsl:for-each>
+            </ul>
+          </xsl:if>
+          <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist"/>
+        </body>
+      </html>
+    </exsl:document>
+  </xsl:template>
+
+  <xsl:template name="html5-doctype">
+    <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html&gt;</xsl:text>
+    <xsl:call-template name="whitespace-newline"/>
+  </xsl:template>
+
+  <xsl:template match="*" mode="html5-charset">
+    <xsl:text disable-output-escaping='yes'>&lt;meta charset="UTF-8" /&gt;</xsl:text>
+    <xsl:call-template name="whitespace-newline"/>
+  </xsl:template>
+
+  <xsl:template name="whitespace-newline">
+    <xsl:text>&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="title" mode="html-head">
+      <xsl:apply-templates select="." mode="html5-charset"/>
+      <title><xsl:value-of select="text()"/> - <xsl:value-of select="/article/section/title"/></title>
+      <link rel="stylesheet" type="text/css" href="default.css"/>
+  </xsl:template>
+
+  <xsl:template match="article">
+    <xsl:apply-templates select="articleinfo|section"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/title">
+    <div class="header">
+      <a href="index.html"><xsl:value-of select="."/></a>
+    </div>
+    <h1><xsl:value-of select="."/></h1>
+  </xsl:template>
+
+  <xsl:template match="article/section" mode="toc">
+      <xsl:apply-templates select="title"/>
+      <ul class="toc">
+        <xsl:for-each select="section">
+          <li>
+            <xsl:call-template name="linkto">
+              <xsl:with-param name="page" select="title"/>
+              <xsl:with-param name="title" select="title"/>
+            </xsl:call-template>
+            <xsl:if test="count(section) > 0">
+              <xsl:call-template name="whitespace-newline"/>
+              <ul>
+                <xsl:for-each select="section">
+                  <li>
+                    <xsl:call-template name="linkto">
+                      <xsl:with-param name="page" select="../title"/>
+                      <xsl:with-param name="subpage" select="title"/>
+                      <xsl:with-param name="title" select="title"/>
+                    </xsl:call-template>
+                  </li>
+                </xsl:for-each>
+              </ul>
+            </xsl:if>
+          </li>
+        </xsl:for-each>
+      </ul>
+      <xsl:apply-templates select="section"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/title">
+    <h2><xsl:value-of select="."/></h2>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section">
+    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section/title">
+    <xsl:variable name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:call-template name="whitespace-newline"/>
+    <xsl:call-template name="whitespace-newline"/>
+    <h3 id="{$id}"><xsl:value-of select="."/></h3>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section/section">
+    <xsl:apply-templates select="para|section|programlisting|screen|itemizedlist|title|informaltable"/>
+  </xsl:template>
+
+  <xsl:template match="article/section/section/section/section/title">
+    <xsl:variable name="id">
+      <xsl:call-template name="normalizepath">
+        <xsl:with-param name="title" select="."/>
+      </xsl:call-template>
+    </xsl:variable>
+    <h4><xsl:value-of select="."/><a name="{$id}">&#160;</a></h4>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <p><xsl:apply-templates select="text()|code|ulink|emphasis"/></p>
+  </xsl:template>
+
+  <xsl:template match="emphasis">
+    <strong><xsl:apply-templates select="text()"/></strong>
+  </xsl:template>
+
+  <xsl:template match="ulink">
+    <xsl:if 
test="starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/')">
+      <xsl:variable name="pageid">
+        <xsl:call-template name="normalizepath">
+          <xsl:with-param name="title" select="str:decode-uri(str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[1])"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <a href="{$pageid}.html#{str:tokenize(substring-after(@url, 
'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'),'#')[2]}"><xsl:value-of 
select="."/></a>
+    </xsl:if>
+    <xsl:if 
test="not(starts-with(@url,'http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/'))">
+      <a href="{@url}"><xsl:value-of select="."/></a>
+    </xsl:if>
+  </xsl:template>
+
+
+  <xsl:template match="para/code">
+    <xsl:if test="contains (text(), '&#x0a;')">
+      <pre><xsl:value-of select="text()"/></pre>
+    </xsl:if>
+    <xsl:if test="not (contains (text(), '&#x0a;'))">
+      <code><xsl:value-of select="text()"/></code>
+    </xsl:if>
+  </xsl:template>
 
+  <xsl:template match="screen">
+    <pre><xsl:value-of select="text()"/></pre>
+  </xsl:template>
+
+  <!-- program listing -->
+  <xsl:template match="programlisting">
+    <pre class="o-box c-program"><xsl:apply-templates 
select="text()|type|methodname|token|phrase|lineannotation"/></pre>
+  </xsl:template>
+
+  <xsl:template match="type">
+    <span class="c-program-type"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="token">
+    <span class="c-program-token"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="methodname">
+    <span class="c-program-methodname"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="lineannotation">
+    <span class="c-program-comment"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="phrase">
+    <span class="c-program-phrase"><xsl:value-of select="."/></span>
+  </xsl:template>
+
+  <xsl:template match="programlisting/text()[. = '&#10;'][preceding-sibling::*[1][self::phrase]]">
+    <span class="c-program-phrase"><xsl:text>\n</xsl:text></span>
+  </xsl:template>
+
+  <xsl:template match="programlisting/text()[. = '&#10;&#10;'][preceding-sibling::*[1][self::phrase]]">
+    <span class="c-program-phrase"><xsl:text>\n\n</xsl:text></span>
+  </xsl:template>
+
+  <!-- lists -->
+  <xsl:template match="itemizedlist[listitem[not(@override)]]">
+    <ul><xsl:apply-templates select="listitem"/></ul>
+  </xsl:template>
+
+  <xsl:template match="listitem[not(@override)]">
+    <li><xsl:apply-templates select="para"/></li>
+  </xsl:template>
+
+  <xsl:template match="itemizedlist[listitem[@override='none']]">
+    <blockquote class="o-box c-rules"><xsl:apply-templates select="listitem"/></blockquote>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/itemizedlist"><xsl:apply-templates 
select="listitem"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <xsl:template match="listitem[@override='none']">
+    <xsl:apply-templates select="para|itemizedlist"/>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para"><xsl:apply-templates 
select="text()|emphasis"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para/text()">
+    <xsl:if test="position()=1 and starts-with(.,' ')">
+      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="substring-after(.,' ')"/></xsl:if>
+    </xsl:if>
+    <xsl:if test="position()!=1 or not(starts-with(.,' '))">
+      <xsl:if test="normalize-space(.)!=''"><xsl:value-of select="."/></xsl:if>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="listitem[@override='none']/para/emphasis[@role='strong']"><span 
class="literal"><xsl:value-of select="."/></span></xsl:template>
+<xsl:template 
match="listitem[@override='none']/itemizedlist/listitem[@override='none']/para"><xsl:text>&#x09;</xsl:text><xsl:apply-templates
 select="text()|emphasis"/><xsl:text>
+</xsl:text></xsl:template>
+
+  <!-- tables -->
+  <xsl:template match="informaltable">
+    <table class="c-informaltable">
+      <xsl:apply-templates select="tgroup/tbody/row"/>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="row">
+    <tr>
+      <xsl:apply-templates select="entry"/>
+    </tr>
+  </xsl:template>
+
+  <xsl:template match="entry">
+    <td xsl:use-attribute-sets="entry-attrs">
+      <xsl:apply-templates select="para"/>
+    </td>
+  </xsl:template>
+
+  <xsl:attribute-set name="entry-attrs">
+    <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
+    <xsl:attribute name="colspan">
+      <xsl:if test="@nameend"><xsl:value-of select="number(substring-after(@nameend, 'col_'))+1"/></xsl:if>
+    </xsl:attribute>
+  </xsl:attribute-set>
+
+</xsl:stylesheet>


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