From e3ecb42e32b7daa07b327b2f40f757f0206fb484 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 18 Oct 2017 13:50:51 +0200 Subject: 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 --- external/libepubgen/libepubgen-epub3.patch.1 | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'external/libepubgen') 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 +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 + -- cgit