mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
better support for <pre>formatted text in ePubs
This commit is contained in:
parent
64fab160e9
commit
646f31535c
3 changed files with 12 additions and 11 deletions
|
@ -17,7 +17,7 @@
|
|||
<style id="7" name="Stanza" spaceBefore="6" spaceAfter="6" alignment="left" allowHyphenations="false"/>
|
||||
<style id="8" name="Verse" leftIndent="20" alignment="left" allowHyphenations="false"/>
|
||||
<style id="10" name="Image" spaceBefore="8" alignment="center"/>
|
||||
<style id="9" name="Preformatted text" italic="true" alignment="left" allowHyphenations="false"/>
|
||||
<style id="9" name="Preformatted text" family="Monospace" alignment="left" allowHyphenations="false"/>
|
||||
|
||||
<style id="12" partial="true" name="Cite" italic="true"/>
|
||||
<style id="15" partial="true" name="Internal Hyperlink" allowHyphenations="false" underline="true"/>
|
||||
|
|
|
@ -138,6 +138,7 @@ void BookReader::addStyleCloseEntry() {
|
|||
|
||||
void BookReader::addFixedHSpace(unsigned char length) {
|
||||
if (paragraphIsOpen()) {
|
||||
flushTextBufferToParagraph();
|
||||
myCurrentTextModel->addFixedHSpace(length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ XHTMLTagParagraphWithControlAction::XHTMLTagParagraphWithControlAction(FBTextKin
|
|||
}
|
||||
|
||||
void XHTMLTagParagraphWithControlAction::doAtStart(XHTMLReader &reader, const char**) {
|
||||
if ((myControl == TITLE) && (bookReader(reader).model().bookTextModel()->paragraphsNumber() > 1)) {
|
||||
if (myControl == TITLE && bookReader(reader).model().bookTextModel()->paragraphsNumber() > 1) {
|
||||
bookReader(reader).insertEndOfSectionParagraph();
|
||||
}
|
||||
bookReader(reader).pushKind(myControl);
|
||||
|
@ -393,11 +393,10 @@ void XHTMLTagParagraphWithControlAction::doAtEnd(XHTMLReader &reader) {
|
|||
void XHTMLTagPreAction::doAtStart(XHTMLReader &reader, const char**) {
|
||||
reader.myPreformatted = true;
|
||||
beginParagraph(reader);
|
||||
bookReader(reader).addControl(CODE, true);
|
||||
bookReader(reader).addControl(PREFORMATTED, true);
|
||||
}
|
||||
|
||||
void XHTMLTagPreAction::doAtEnd(XHTMLReader &reader) {
|
||||
bookReader(reader).addControl(CODE, false);
|
||||
endParagraph(reader);
|
||||
reader.myPreformatted = false;
|
||||
}
|
||||
|
@ -598,7 +597,7 @@ void XHTMLReader::beginParagraph() {
|
|||
}
|
||||
|
||||
if (doBlockSpaceBefore) {
|
||||
ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY);
|
||||
ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_OTHER_ENTRY);
|
||||
blockingEntry.setLength(
|
||||
ZLTextStyleEntry::LENGTH_SPACE_BEFORE,
|
||||
0,
|
||||
|
@ -616,7 +615,7 @@ void XHTMLReader::endParagraph() {
|
|||
(*it)->isFeatureSupported(ZLTextStyleEntry::LENGTH_SPACE_AFTER);
|
||||
}
|
||||
if (doBlockSpaceAfter) {
|
||||
ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_CSS_ENTRY);
|
||||
ZLTextStyleEntry blockingEntry(ZLTextStyleEntry::STYLE_OTHER_ENTRY);
|
||||
blockingEntry.setLength(
|
||||
ZLTextStyleEntry::LENGTH_SPACE_AFTER,
|
||||
0,
|
||||
|
@ -642,20 +641,21 @@ void XHTMLReader::characterDataHandler(const char *text, size_t len) {
|
|||
break;
|
||||
case READ_BODY:
|
||||
if (myPreformatted) {
|
||||
if ((*text == '\r') || (*text == '\n')) {
|
||||
myModelReader.addControl(CODE, false);
|
||||
if (*text == '\r' || *text == '\n') {
|
||||
endParagraph();
|
||||
text += 1;
|
||||
len -= 1;
|
||||
beginParagraph();
|
||||
myModelReader.addControl(CODE, true);
|
||||
myModelReader.addControl(PREFORMATTED, true);
|
||||
}
|
||||
size_t spaceCounter = 0;
|
||||
while ((spaceCounter < len) && isspace((unsigned char)*(text + spaceCounter))) {
|
||||
while (spaceCounter < len && isspace((unsigned char)*(text + spaceCounter))) {
|
||||
++spaceCounter;
|
||||
}
|
||||
myModelReader.addFixedHSpace(spaceCounter);
|
||||
text += spaceCounter;
|
||||
len -= spaceCounter;
|
||||
} else if ((myNewParagraphInProgress) || !myModelReader.paragraphIsOpen()) {
|
||||
} else if (myNewParagraphInProgress || !myModelReader.paragraphIsOpen()) {
|
||||
while (isspace((unsigned char)*text)) {
|
||||
++text;
|
||||
if (--len == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue