mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
nested lists
This commit is contained in:
parent
c82f7d6167
commit
4cbaebfb6f
4 changed files with 20 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -44,6 +44,7 @@ private:
|
|||
std::size_t myParagraphsBeforeBodyNumber;
|
||||
std::string myCoverImageReference;
|
||||
bool myInsidePoem;
|
||||
int myListDepth;
|
||||
BookReader myModelReader;
|
||||
|
||||
int myCurrentImageStart;
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -45,6 +45,8 @@ private:
|
|||
public:
|
||||
enum TagCode {
|
||||
_P,
|
||||
_UL,
|
||||
_OL,
|
||||
_LI,
|
||||
_SUBTITLE,
|
||||
_CITE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue