[yelp-tools] Adapt to recent major changes in yelp-xsl



commit 4daf828149ec8e027ae57d1940d4fd4666cca3f6
Author: Shaun McCance <shaunm gnome org>
Date:   Fri Jul 7 12:04:19 2017 -0400

    Adapt to recent major changes in yelp-xsl

 tools/yelp-build.in |   86 +++++---------------------------------------------
 xslt/mal-files.xsl  |   70 ++---------------------------------------
 2 files changed, 12 insertions(+), 144 deletions(-)
---
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
index a0d4bea..898325b 100755
--- a/tools/yelp-build.in
+++ b/tools/yelp-build.in
@@ -269,14 +269,8 @@ yelp_html_xsl_common () {
     echo ' </exsl:document>'
     echo ' <link rel="stylesheet" type="text/css" href="{$html.css.root}{$yelp.locale}.css"/>'
     echo '</xsl:template>'
-    echo '<xsl:template name="html.js">'
+    echo '<xsl:template name="html.js.script">'
     echo ' <xsl:param name="node" select="."/>'
-    echo ' <xsl:call-template name="html.js.jquery">'
-    echo '  <xsl:with-param name="node" select="$node"/>'
-    echo ' </xsl:call-template>'
-    echo ' <xsl:call-template name="html.js.custom">'
-    echo '  <xsl:with-param name="node" select="$node"/>'
-    echo ' </xsl:call-template>'
     echo ' <exsl:document href="{$yelp.internal.datadir}yelp.js" method="text">'
     echo '  <xsl:call-template name="html.js.content">'
     echo '   <xsl:with-param name="node" select="$node"/>'
@@ -344,67 +338,8 @@ yelp_html_db2html () {
                 fi
             done
         fi
-        # Copy icons
-        (
-            echo '<xsl:stylesheet'
-            echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
-            echo ' xmlns:db="http://docbook.org/ns/docbook";'
-            echo ' exclude-result-prefixes="db"'
-            echo ' version="1.0">'
-            echo '<xsl:output method="text"/>'
-            echo '<xsl:template match="/">'
-            echo ' <xsl:for-each select="(//caution|//warning|//db:caution|//db:warning)[1]">'
-            echo '  <xsl:text>yelp-note-warning&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo ' <xsl:for-each select="(//important|//db:important)[1]">'
-            echo '  <xsl:text>yelp-note-important&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo ' <xsl:for-each select="(//tip|//db:tip)[1]">'
-            echo '  <xsl:text>yelp-note-tip&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo ' <xsl:for-each select="(//note|//db:note)[@role='"'bug'"'][1]">'
-            echo '  <xsl:text>yelp-note-bug&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo ' <xsl:for-each select="(//note|//db:note)[not(@role) or @role!='"'bug'"'][1]">'
-            echo '  <xsl:text>yelp-note&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo '</xsl:template>'
-            echo '</xsl:stylesheet>'
-        ) | xsltproc --path "$html_paths" --xinclude - "$xml" | sort | uniq | while read icon; do
-            cp "${yelp_icon_dir}/${icon}.png" "$html_out/$html_internal_datadir"
-        done;
-        # Copy jQuery
-        cp "${yelp_js_dir}/jquery.js" "$html_out/$html_internal_datadir"
-        cp "${yelp_js_dir}/jquery.syntax.js" "$html_out/$html_internal_datadir"
-        cp "${yelp_js_dir}/jquery.syntax.core.js" "$html_out/$html_internal_datadir"
-        cp "${yelp_js_dir}/jquery.syntax.layout.yelp.js" "$html_out/$html_internal_datadir"
-        (
-            echo '<xsl:stylesheet'
-            echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
-            echo ' xmlns:db="http://docbook.org/ns/docbook";'
-            echo ' xmlns:html="http://www.w3.org/1999/xhtml";'
-            echo ' xmlns:exsl="http://exslt.org/common";'
-            echo ' exclude-result-prefixes="db"'
-            echo ' extension-element-prefixes="exsl"'
-            echo ' version="1.0">'
-            xsl='file://'`echo "$xsl_db2xhtml" | urlencode`
-            echo '<xsl:import href="'"$xsl"'"/>'
-            echo '<xsl:output method="text"/>'
-            echo '<xsl:template match="/">'
-            echo ' <xsl:for-each select="//programlisting[@language] | //db:programlisting[@language]">'
-            echo '  <xsl:variable name="out">'
-            echo '   <xsl:call-template name="db2html.pre"/>'
-            echo '  </xsl:variable>'
-            echo '  <xsl:value-of select="exsl:node-set($out)/*/html:pre[last()]/@class"/>'
-            echo '  <xsl:text>&#x000A;</xsl:text>'
-            echo ' </xsl:for-each>'
-            echo '</xsl:template>'
-            echo '</xsl:stylesheet>'
-        ) | xsltproc --path "$html_paths" --xinclude - "$xml" | sort | uniq \
-            | grep '^contents syntax ' | sed -e 's/^contents syntax brush-/brush./' \
-            | while read js; do
-            cp "${yelp_js_dir}/jquery.syntax.${js}.js" "$html_out/$html_internal_datadir"
-        done
+        # Copy JavaScript
+        cp "${yelp_js_dir}/highlight.pack.js" "$html_out/$html_internal_datadir"
     done
 }
 
@@ -418,6 +353,7 @@ yelp_html_mal2html () {
     fi
     html_tmp_infile=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
     yelp_cache_in "$@" > "$html_tmp_infile"
+    # Output HTML
     (
         echo '<xsl:stylesheet'
         echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform";'
@@ -453,18 +389,11 @@ yelp_html_mal2html () {
         echo '</xsl:stylesheet>'
     ) | (cd "$html_out" && xsltproc $html_profile \
         --path "$html_paths" --xinclude \
-        --stringparam mal.files.copy.icon.dir "$yelp_icon_dir" \
-        --stringparam mal.files.copy.js.dir "$yelp_js_dir" \
         - "$html_tmp_infile") | sort | uniq | \
     while read line; do
-        use_internal_datadir=$(echo "$line" | cut -c1)
-        line=$(echo "$line" | cut -c2-)
+        # Copy media from paths output by HTML transform
         line_src=$(echo "$line" | cut -d' ' -f1 | urldecode)
-        if [ "x$use_internal_datadir" = "x+" ]; then
-            line_dest="$html_out/$html_internal_datadir"$(echo "$line" | cut -d' ' -f2)
-        else
-            line_dest="$html_out/"$(echo "$line" | cut -d' ' -f2)
-        fi
+        line_dest="$html_out/"$(echo "$line" | cut -d' ' -f2)
         if [ ! -f "$line_src" -a "x$html_paths" != "x" ]; then
             line_src_rel=${line_src#"$(pwd)/"}
             if [ "x$line_src_rel" != "x$line_src" ]; then
@@ -485,6 +414,9 @@ yelp_html_mal2html () {
             fi
         fi
     done
+    # Copy JavaScript
+    cp "${yelp_js_dir}/highlight.pack.js" "$html_out/$html_internal_datadir"
+    # Clean up
     rm "$html_tmp_infile"
     if [ "x$html_cache_file_is_tmp" = "xyes" ]; then
         rm "$html_cache_file"
diff --git a/xslt/mal-files.xsl b/xslt/mal-files.xsl
index cea85fd..c955a9e 100644
--- a/xslt/mal-files.xsl
+++ b/xslt/mal-files.xsl
@@ -9,16 +9,9 @@
     xmlns:html="http://www.w3.org/1999/xhtml";
     version="1.0">
 
-<xsl:param name="mal.files.copy.icon.dir"/>
-<xsl:param name="mal.files.copy.js.dir"/>
-
 <xsl:template name="mal.files.copy">
   <xsl:param name="node" select="."/>
   <xsl:param name="href"/>
-  <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.js ./&#x000A;')"/>
-  <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.js ./&#x000A;')"/>
-  <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.core.js ./&#x000A;')"/>
-  <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.layout.yelp.js ./&#x000A;')"/>
   <xsl:apply-templates mode="mal.files.copy.block.mode">
     <xsl:with-param name="dir">
       <xsl:call-template name="mal.files.copy.dirname">
@@ -44,7 +37,7 @@
 <xsl:template mode="mal.files.copy.media.mode" match="mal:media | e:mouseover | ui:thumb | uix:thumb">
   <xsl:param name="dir"/>
   <xsl:if test="not(contains(@src, ':') or substring(@src, 1, 1) = '/')">
-    <xsl:value-of select="concat('-', $dir, @src, ' ', @src, '&#x000A;')"/>
+    <xsl:value-of select="concat($dir, @src, ' ', @src, '&#x000A;')"/>
   </xsl:if>
 </xsl:template>
 
@@ -75,7 +68,7 @@
   </xsl:apply-templates>
 </xsl:template>
 
-<xsl:template mode="mal.files.copy.block.mode" match="mal:p | mal:screen">
+<xsl:template mode="mal.files.copy.block.mode" match="mal:p | mal:screen | mal:code">
   <xsl:param name="dir"/>
   <xsl:variable name="if">
     <xsl:call-template name="mal.if.test"/>
@@ -94,32 +87,11 @@
   </xsl:apply-templates>
 </xsl:template>
 
-<xsl:template mode="mal.files.copy.block.mode" match="mal:code">
-  <xsl:param name="dir"/>
-  <xsl:variable name="if">
-    <xsl:call-template name="mal.if.test"/>
-  </xsl:variable>
-  <xsl:if test="$if != ''">
-    <xsl:apply-templates mode="mal.files.copy.media.mode" select=".//mal:media">
-      <xsl:with-param name="dir" select="$dir"/>
-    </xsl:apply-templates>
-    <xsl:if test="$html.syntax.highlight and @mime">
-      <xsl:variable name="brush">
-        <xsl:call-template name="html.syntax.class"/>
-      </xsl:variable>
-      <xsl:if test="starts-with($brush, 'syntax brush-')">
-        <xsl:value-of select="concat('+', $mal.files.copy.js.dir, '/jquery.syntax.brush.',
-                              substring-after($brush,  'syntax brush-'), '.js ./&#x000A;')"/>
-      </xsl:if>
-    </xsl:if>
-  </xsl:if>
-</xsl:template>
-
 <xsl:template mode="mal.files.copy.block.mode"
               match="mal:example | mal:quote | mal:listing | mal:figure |
                      mal:synopsis | mal:links | mal:list | mal:steps |
                      mal:terms | mal:tree | mal:item | mal:table |
-                     mal:section | if:if">
+                     mal:note | mal:section | if:if">
   <xsl:param name="dir"/>
   <xsl:variable name="if">
     <xsl:call-template name="mal.if.test"/>
@@ -158,42 +130,6 @@
   </xsl:if>
 </xsl:template>
 
-<xsl:template mode="mal.files.copy.block.mode" match="mal:note">
-  <xsl:param name="dir"/>
-  <xsl:variable name="if">
-    <xsl:call-template name="mal.if.test"/>
-  </xsl:variable>
-  <xsl:if test="$if != ''">
-    <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
-    <xsl:choose>
-      <!--
-        <xsl:when test="contains($style, ' advanced ')">
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-advanced.png ./&#x000A;')"/>
-        </xsl:when>
-      -->
-      <xsl:when test="contains($style, ' bug ')">
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-bug.png ./&#x000A;')"/>
-      </xsl:when>
-      <xsl:when test="contains($style, ' important ')">
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-important.png ./&#x000A;')"/>
-      </xsl:when>
-      <xsl:when test="contains($style, ' sidebar ')"/>
-      <xsl:when test="contains($style, ' tip ')">
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-tip.png ./&#x000A;')"/>
-      </xsl:when>
-      <xsl:when test="contains($style, ' warning ')">
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note-warning.png ./&#x000A;')"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="concat('+', $mal.files.copy.icon.dir, '/yelp-note.png ./&#x000A;')"/>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:apply-templates mode="mal.files.copy.block.mode">
-      <xsl:with-param name="dir" select="$dir"/>
-    </xsl:apply-templates>
-  </xsl:if>
-</xsl:template>
-
 <xsl:template mode="mal.files.copy.block.mode" match="mal:tr | mal:td"> 
   <xsl:param name="dir"/>
   <xsl:apply-templates mode="mal.files.copy.block.mode">


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