1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

ePub: no empty paragraph before & after cover image

This commit is contained in:
Nikolay Pultsin 2013-08-18 19:28:27 +01:00
parent dcec516e0f
commit eb425467fe
2 changed files with 17 additions and 5 deletions

View file

@ -19,6 +19,7 @@
#include <algorithm> #include <algorithm>
//#include <ZLLogger.h>
#include <ZLStringUtil.h> #include <ZLStringUtil.h>
#include <ZLUnicodeUtil.h> #include <ZLUnicodeUtil.h>
#include <ZLFile.h> #include <ZLFile.h>
@ -203,6 +204,7 @@ bool OEBBookReader::readBook(const ZLFile &file) {
myModelReader.setMainTextModel(); myModelReader.setMainTextModel();
myModelReader.pushKind(REGULAR); myModelReader.pushKind(REGULAR);
//ZLLogger::Instance().registerClass("oeb");
XHTMLReader xhtmlReader(myModelReader); XHTMLReader xhtmlReader(myModelReader);
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) { for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
const ZLFile xhtmlFile(myFilePrefix + *it); const ZLFile xhtmlFile(myFilePrefix + *it);
@ -219,7 +221,12 @@ bool OEBBookReader::readBook(const ZLFile &file) {
} else { } else {
myModelReader.insertEndOfSectionParagraph(); myModelReader.insertEndOfSectionParagraph();
} }
//ZLLogger::Instance().println("oeb", "start " + xhtmlFile.path());
xhtmlReader.readFile(xhtmlFile, *it); xhtmlReader.readFile(xhtmlFile, *it);
//ZLLogger::Instance().println("oeb", "end " + xhtmlFile.path());
//std::string debug = "para count = ";
//ZLStringUtil::appendNumber(debug, myModelReader.model().bookTextModel()->paragraphsNumber());
//ZLLogger::Instance().println("oeb", debug);
} }
generateTOC(xhtmlReader); generateTOC(xhtmlReader);

View file

@ -303,16 +303,21 @@ void XHTMLTagImageAction::doAtStart(XHTMLReader &reader, const char **xmlattribu
return; return;
} }
bool flag = bookReader(reader).paragraphIsOpen(); const bool flagParagraphIsOpen = bookReader(reader).paragraphIsOpen();
if (flag) { if (flagParagraphIsOpen) {
if (reader.myCurrentParagraphIsEmpty) {
bookReader(reader).addControl(IMAGE, true);
} else {
endParagraph(reader); endParagraph(reader);
} }
}
const std::string imageName = imageFile.name(false); const std::string imageName = imageFile.name(false);
bookReader(reader).addImageReference(imageName, 0, reader.myMarkNextImageAsCover); bookReader(reader).addImageReference(imageName, 0, reader.myMarkNextImageAsCover);
bookReader(reader).addImage(imageName, new ZLFileImage(imageFile, "", 0)); bookReader(reader).addImage(imageName, new ZLFileImage(imageFile, "", 0));
reader.myMarkNextImageAsCover = false; reader.myMarkNextImageAsCover = false;
if (flag) { if (flagParagraphIsOpen && reader.myCurrentParagraphIsEmpty) {
beginParagraph(reader); bookReader(reader).addControl(IMAGE, false);
endParagraph(reader);
} }
} }