]> granicus.if.org Git - docbook-dsssl/commitdiff
Remove <b> and <i> elements "discouraged in favor of style sheets" from
authorKeith Fahlgren <abdelazer@users.sourceforge.net>
Sat, 10 Oct 2009 02:45:47 +0000 (02:45 +0000)
committerKeith Fahlgren <abdelazer@users.sourceforge.net>
Sat, 10 Oct 2009 02:45:47 +0000 (02:45 +0000)
XHTML, XHTML 1.1 (and therefore EPUB) outputs by changing html2xhtml.xsl.

Fixes bug #2873153: No <b> and <i> tags in XHTML/EPUB

Added regression to EPUB specs:

xsl/epub/bin/spec/epub_regressions_spec.rb
xsl/html/inline.xsl
xsl/html/lists.xsl
xsl/xhtml-1_1/html2xhtml.xsl
xsl/xhtml/html2xhtml.xsl

index 512f85bcf1c2c5adbbd5d60435cd229454bcb4f8..2be252200a0e0db996888444449f1f0fbb782ccc 100755 (executable)
@@ -190,6 +190,31 @@ describe DocBook::Epub do
     opf_lns.to_s.should =~ /<itemref idref="#{before_refentry_id}"[^>]*[^<]*<itemref idref="#{re01_id}"[^>]*>[^<]*<itemref idref="#{re02_id}"/m
   end
 
+  it "should not include font style elements like <b> or <i>" do
+    begin
+      tmpdir = File.join(Dir::tmpdir(), "epubbtest"); Dir.mkdir(tmpdir) rescue Errno::EEXIST
+      
+      epub = DocBook::Epub.new(File.join(@testdocsdir, "book.002.xml"), @tmpdir)
+      epubfile = File.join(tmpdir, "bcount.epub")
+      epub.render_to_file(epubfile, $DEBUG)
+      FileUtils.copy(epubfile, ".b.epub") if $DEBUG
+
+      success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}")
+      raise "Could not unzip #{epubfile}" unless success
+      glob = Dir.glob(File.join(tmpdir, "**", "*.html"))
+      glob.each {|html_file| 
+        bs = File.open(html_file).readlines.to_s.scan(/<b>/)
+        bs.should be_empty
+        is = File.open(html_file).readlines.to_s.scan(/<i>/)
+        is.should be_empty
+      }
+    rescue => e
+      raise e
+    ensure
+      FileUtils.rm_r(tmpdir, :force => true)
+    end  
+  end  
+
   after(:all) do
     FileUtils.rm_r(@tmpdir, :force => true)
   end  
index dca5d188f3f6d7e6811d575a5123cb59a95c6422..2a946cb7a97195a3308d06422f42865a75aa6ce6 100644 (file)
 
 <xsl:template match="comment[&comment.block.parents;]|remark[&comment.block.parents;]">
   <xsl:if test="$show.comments != 0">
-    <p class="remark"><i><xsl:call-template name="inline.charseq"/></i></p>
+    <p class="remark"><em><xsl:call-template name="inline.charseq"/></em></p>
   </xsl:if>
 </xsl:template>
 
index 0ac08a55cb09355b6935bed86e78abd3960c63e3..81558a91657234eace39a4a1f6499e2df730735f 100644 (file)
       <xsl:call-template name="anchor"/>
       <xsl:choose>
         <xsl:when test="$presentation = 'bold'">
-          <b>
+          <strong>
             <xsl:apply-templates select="term"/>
             <xsl:value-of select="$separator"/>
-          </b>
+          </strong>
         </xsl:when>
         <xsl:when test="$presentation = 'italic'">
-          <i>
+          <em>
             <xsl:apply-templates select="term"/>
             <xsl:value-of select="$separator"/>
-          </i>
+          </em>
         </xsl:when>
         <xsl:when test="$presentation = 'bold-italic'">
-          <b>
-            <i>
+          <strong>
+            <em>
               <xsl:apply-templates select="term"/>
               <xsl:value-of select="$separator"/>
-            </i>
-          </b>
+            </em>
+          </strong>
         </xsl:when>
         <xsl:otherwise>
           <xsl:apply-templates select="term"/>
index d125605042ddb2c8fe6a2d00f2bcfddaae7178ed..050f33cacca17409ded6c331f81b1fb6813e7696 100644 (file)
   </xsl:copy>
 </xsl:template>
 
+<!-- "The following HTML elements specify font information. 
+      Although they are not all deprecated, their use is discouraged in 
+      favor of style sheets." -->
+<xsl:template match="b|i"/>
+
 <!-- this only occurs in docbook.xsl to identify errors -->
 <xsl:template match="font">
   <span class="ERROR" xmlns="http://www.w3.org/1999/xhtml">
index 0de1517cb2168c8e086614687c6bae52cf50fe47..1350210271e602b777056acd97242a9455ff395c 100644 (file)
   </span>
 </xsl:template>
 
+<!-- "The following HTML elements specify font information. 
+      Although they are not all deprecated, their use is discouraged in 
+      favor of style sheets." -->
+<xsl:template match="b|i"/>
+
 <!-- this only occurs in docbook.xsl to identify errors -->
 <xsl:template match="a[@name]">
   <xsl:element name="{local-name(.)}" namespace="http://www.w3.org/1999/xhtml">