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;
|
myCurrentImageStart = -1;
|
||||||
mySectionStarted = false;
|
mySectionStarted = false;
|
||||||
myInsideTitle = false;
|
myInsideTitle = false;
|
||||||
|
myListDepth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FB2BookReader::characterDataHandler(const char *text, std::size_t len) {
|
void FB2BookReader::characterDataHandler(const char *text, std::size_t len) {
|
||||||
|
@ -80,14 +81,22 @@ void FB2BookReader::startElementHandler(int tag, const char **xmlattributes) {
|
||||||
}
|
}
|
||||||
myModelReader.beginParagraph();
|
myModelReader.beginParagraph();
|
||||||
break;
|
break;
|
||||||
|
case _UL:
|
||||||
|
case _OL:
|
||||||
|
++myListDepth;
|
||||||
|
break;
|
||||||
case _LI:
|
case _LI:
|
||||||
{
|
{
|
||||||
if (mySectionStarted) {
|
if (mySectionStarted) {
|
||||||
mySectionStarted = false;
|
mySectionStarted = false;
|
||||||
}
|
}
|
||||||
myModelReader.beginParagraph();
|
myModelReader.beginParagraph();
|
||||||
static const std::string BULLET_NBSP = "\xE2\x80\xA2\xC0\xA0";
|
static const std::string BULLET = "\xE2\x80\xA2";
|
||||||
myModelReader.addData(BULLET_NBSP);
|
if (myListDepth > 1) {
|
||||||
|
myModelReader.addFixedHSpace(3 * (myListDepth - 1));
|
||||||
|
}
|
||||||
|
myModelReader.addData(BULLET);
|
||||||
|
myModelReader.addFixedHSpace(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _V:
|
case _V:
|
||||||
|
@ -251,6 +260,10 @@ void FB2BookReader::endElementHandler(int tag) {
|
||||||
case _LI:
|
case _LI:
|
||||||
myModelReader.endParagraph();
|
myModelReader.endParagraph();
|
||||||
break;
|
break;
|
||||||
|
case _UL:
|
||||||
|
case _OL:
|
||||||
|
--myListDepth;
|
||||||
|
break;
|
||||||
case _V:
|
case _V:
|
||||||
case _SUBTITLE:
|
case _SUBTITLE:
|
||||||
case _TEXT_AUTHOR:
|
case _TEXT_AUTHOR:
|
||||||
|
|
|
@ -44,6 +44,7 @@ private:
|
||||||
std::size_t myParagraphsBeforeBodyNumber;
|
std::size_t myParagraphsBeforeBodyNumber;
|
||||||
std::string myCoverImageReference;
|
std::string myCoverImageReference;
|
||||||
bool myInsidePoem;
|
bool myInsidePoem;
|
||||||
|
int myListDepth;
|
||||||
BookReader myModelReader;
|
BookReader myModelReader;
|
||||||
|
|
||||||
int myCurrentImageStart;
|
int myCurrentImageStart;
|
||||||
|
|
|
@ -38,6 +38,8 @@ void FB2Reader::endElementHandler(const char *t) {
|
||||||
|
|
||||||
static const FB2Reader::Tag TAGS[] = {
|
static const FB2Reader::Tag TAGS[] = {
|
||||||
{"p", FB2Reader::_P},
|
{"p", FB2Reader::_P},
|
||||||
|
{"ul", FB2Reader::_UL},
|
||||||
|
{"ol", FB2Reader::_OL},
|
||||||
{"li", FB2Reader::_LI},
|
{"li", FB2Reader::_LI},
|
||||||
{"subtitle", FB2Reader::_SUBTITLE},
|
{"subtitle", FB2Reader::_SUBTITLE},
|
||||||
{"cite", FB2Reader::_CITE},
|
{"cite", FB2Reader::_CITE},
|
||||||
|
|
|
@ -45,6 +45,8 @@ private:
|
||||||
public:
|
public:
|
||||||
enum TagCode {
|
enum TagCode {
|
||||||
_P,
|
_P,
|
||||||
|
_UL,
|
||||||
|
_OL,
|
||||||
_LI,
|
_LI,
|
||||||
_SUBTITLE,
|
_SUBTITLE,
|
||||||
_CITE,
|
_CITE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue