[Libreoffice-commits] core.git: external/libepubgen writerperfect/qa

Miklos Vajna vmiklos at collabora.co.uk
Wed Oct 18 18:31:31 UTC 2017


 external/libepubgen/libepubgen-epub3.patch.1 |   48 +++++++++++++++++++++++++++
 writerperfect/qa/unit/EPUBExportTest.cxx     |    2 -
 2 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit e3ecb42e32b7daa07b327b2f40f757f0206fb484
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 18 13:50:51 2017 +0200

    EPUB export: better handling of tabs
    
    Mapping ODF/librevenge tab to \t in HTML is not a great idea, as it's
    ignorable whitespace. Go with NBSPs and a breakable space instead, that
    is much closer visually (15 is just an arbitrary number, it's what MS
    Word uses in its HTML export, LO Writer HTML export doesn't handle
    this).
    
    Adapt the empty paragraph case to also use NBSP for consistency.
    
    Change-Id: I131802416499eb4f3a83a333b37ca20b59fcd56a

diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1
index 01d88d4da380..d6f41f13f61e 100644
--- a/external/libepubgen/libepubgen-epub3.patch.1
+++ b/external/libepubgen/libepubgen-epub3.patch.1
@@ -2557,3 +2557,51 @@ index 26675af..5d4e8f2 100644
 -- 
 2.12.3
 
+From c5bb9ad8922c9f537f0d613d42c33487717455c3 Mon Sep 17 00:00:00 2001
+From: Miklos Vajna <vmiklos at collabora.co.uk>
+Date: Wed, 18 Oct 2017 10:52:01 +0200
+Subject: [PATCH] EPUBHTMLGenerator: better handling of tabs
+
+Mapping ODF/librevenge tab to \t in HTML is not a great idea, as it's
+ignorable whitespace. Go with NBSPs and a breakable space instead, that
+is much closer visually (15 is just an arbitrary number, it's what MS
+Word uses in its HTML export, LO Writer HTML export doesn't handle
+this).
+
+Adapt the empty paragraph case to also use NBSP for consistency.
+---
+ src/lib/EPUBHTMLGenerator.cpp      | 10 +++++++---
+ src/test/EPUBTextGeneratorTest.cpp | 18 +++++++++++++++++-
+ 2 files changed, 24 insertions(+), 4 deletions(-)
+
+diff --git a/src/lib/EPUBHTMLGenerator.cpp b/src/lib/EPUBHTMLGenerator.cpp
+index 11bf7de..25294c6 100644
+--- a/src/lib/EPUBHTMLGenerator.cpp
++++ b/src/lib/EPUBHTMLGenerator.cpp
+@@ -617,7 +617,7 @@ void EPUBHTMLGenerator::closeParagraph()
+     return;
+ 
+   if (!m_impl->m_hasText)
+-    insertLineBreak();
++    insertSpace();
+ 
+   m_impl->output().closeElement("p");
+ }
+@@ -687,8 +687,12 @@ void EPUBHTMLGenerator::insertTab()
+   if (m_impl->m_ignore)
+     return;
+ 
+-  // Does not have a lot of effect since tabs in html are ignorable white-space
+-  m_impl->output().insertCharacters("\t");
++  // \t would not have a lot of effect since tabs in html are ignorable
++  // white-space. Write NBSPs and a breakable space instead.
++  for (int i = 0; i < 15; ++i)
++    m_impl->output().insertCharacters("\xc2\xa0");
++  m_impl->output().insertCharacters(" ");
++  m_impl->m_hasText = true;
+ }
+ 
+ void EPUBHTMLGenerator::insertLineBreak()
+-- 
+2.12.3
+
diff --git a/writerperfect/qa/unit/EPUBExportTest.cxx b/writerperfect/qa/unit/EPUBExportTest.cxx
index 850228c0a276..e9f1ee8743df 100644
--- a/writerperfect/qa/unit/EPUBExportTest.cxx
+++ b/writerperfect/qa/unit/EPUBExportTest.cxx
@@ -400,7 +400,7 @@ void EPUBExportTest::testEscape()
     // Make sure escaping happens only once.
     assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[2]", "a&b");
     // This was also lost.
-    assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", "\t");
+    assertXPathContent(mpXmlDoc, "//xhtml:p[1]/xhtml:span[3]", OUString::fromUtf8("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0 "));
 }
 
 void EPUBExportTest::testParaCharProps()


More information about the Libreoffice-commits mailing list