1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 01:39:18 +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 <ZLLogger.h>
#include <ZLStringUtil.h>
#include <ZLUnicodeUtil.h>
#include <ZLFile.h>
@ -203,6 +204,7 @@ bool OEBBookReader::readBook(const ZLFile &file) {
myModelReader.setMainTextModel();
myModelReader.pushKind(REGULAR);
//ZLLogger::Instance().registerClass("oeb");
XHTMLReader xhtmlReader(myModelReader);
for (std::vector<std::string>::const_iterator it = myHtmlFileNames.begin(); it != myHtmlFileNames.end(); ++it) {
const ZLFile xhtmlFile(myFilePrefix + *it);
@ -219,7 +221,12 @@ bool OEBBookReader::readBook(const ZLFile &file) {
} else {
myModelReader.insertEndOfSectionParagraph();
}
//ZLLogger::Instance().println("oeb", "start " + xhtmlFile.path());
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);

View file

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