1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 02:09:35 +02:00

nested lists

This commit is contained in:
Nikolay Pultsin 2013-02-17 15:48:55 +04:00
parent c82f7d6167
commit 4cbaebfb6f
4 changed files with 20 additions and 2 deletions

View file

@ -40,6 +40,7 @@ FB2BookReader::FB2BookReader(BookModel &model) : myModelReader(model) {
myCurrentImageStart = -1;
mySectionStarted = false;
myInsideTitle = false;
myListDepth = 0;
}
void FB2BookReader::characterDataHandler(const char *text, std::size_t len) {
@ -80,14 +81,22 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) {
}
myModelReader.beginParagraph();
break;
case _UL:
case _OL:
++myListDepth;
break;
case _LI:
{
if (mySectionStarted) {
mySectionStarted = false;
}
myModelReader.beginParagraph();
static const std::string BULLET_NBSP = "\xE2\x80\xA2\xC0\xA0";
myModelReader.addData(BULLET_NBSP);
static const std::string BULLET = "\xE2\x80\xA2";
if (myListDepth > 1) {
myModelReader.addFixedHSpace(3 * (myListDepth - 1));
}
myModelReader.addData(BULLET);
myModelReader.addFixedHSpace(1);
break;
}
case _V:
@ -251,6 +260,10 @@ void FB2BookReader::endElementHandler(int tag) {
case _LI:
myModelReader.endParagraph();
break;
case _UL:
case _OL:
--myListDepth;
break;
case _V:
case _SUBTITLE:
case _TEXT_AUTHOR:

View file

@ -44,6 +44,7 @@ private:
std::size_t myParagraphsBeforeBodyNumber;
std::string myCoverImageReference;
bool myInsidePoem;
int myListDepth;
BookReader myModelReader;
int myCurrentImageStart;

View file

@ -38,6 +38,8 @@ void FB2Reader::endElementHandler(const char *t) {
static const FB2Reader::Tag TAGS[] = {
{"p", FB2Reader::_P},
{"ul", FB2Reader::_UL},
{"ol", FB2Reader::_OL},
{"li", FB2Reader::_LI},
{"subtitle", FB2Reader::_SUBTITLE},
{"cite", FB2Reader::_CITE},

View file

@ -45,6 +45,8 @@ private:
public:
enum TagCode {
_P,
_UL,
_OL,
_LI,
_SUBTITLE,
_CITE,