summaryrefslogtreecommitdiff
path: root/src/backend/filters/osistohtml.h
blob: ca36fe638b1339ef896bee0e35da1de3cb8627b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef FILTERS_OSISTOHTML_H
#define FILTERS_OSISTOHTML_H

// Sword includes:
#include <osishtmlhref.h>
#include <swbuf.h>
#include <swmodule.h>

namespace Filters {

/**
  \brief OSIS to HTMl conversion filter.
*/
class OsisToHtml: public sword::OSISHTMLHREF {
    protected: /* Types: */
        class UserData: public sword::OSISHTMLHREF::MyUserData {
            public:
                inline UserData(const sword::SWModule *module,
                                const sword::SWKey *key)
                     : sword::OSISHTMLHREF::MyUserData(module, key),
                       swordFootnote(1), inCrossrefNote(false),
                       entryAttributes(module->getEntryAttributes()),
                       noteType(Unknown) {}

                unsigned short int swordFootnote;
                bool inCrossrefNote;
                sword::AttributeTypeList entryAttributes;

                enum NoteType {
                    Unknown,
                    Alternative,
                    CrossReference,
                    Footnote,
                    StrongsMarkup
                } noteType;

                struct {
                    sword::SWBuf who;
                } quote;
        };

    public: /* Methods: */
        OsisToHtml();

        /** Reimplemented from sword::OSISHTMLHREF. */
        virtual bool handleToken(sword::SWBuf &buf,
                                 const char *token,
                                 sword::BasicFilterUserData *userData);

    protected: /* Methods: */
        /** Reimplemented from sword::OSISHTMLHREF. */
        virtual inline sword::BasicFilterUserData *createUserData(
                const sword::SWModule *module,
                const sword::SWKey *key)
        {
            return new UserData(module, key);
        }

    private: /* Methods: */
        void renderReference(const char *osisRef, sword::SWBuf &buf,
                             sword::SWModule *myModule, UserData *myUserData);
};

} // namespace Filters

#endif