diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/drivers/cswordlexiconmoduleinfo.cpp | 42 | ||||
-rw-r--r-- | src/backend/drivers/cswordlexiconmoduleinfo.h | 30 | ||||
-rw-r--r-- | src/backend/filters/osistohtml.cpp | 14 | ||||
-rw-r--r-- | src/backend/managers/clanguagemgr.cpp | 3 | ||||
-rw-r--r-- | src/backend/rendering/btinforendering.cpp | 4 | ||||
-rw-r--r-- | src/backend/rendering/chtmlexportrendering.cpp | 6 |
6 files changed, 89 insertions, 10 deletions
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp index d523fa0..5b1e704 100644 --- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp +++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp @@ -11,6 +11,7 @@ #include <QFile> #include <QDataStream> +#include <QRegExp> #include <QTextCodec> #include <QDebug> @@ -113,3 +114,44 @@ const QStringList &CSwordLexiconModuleInfo::entries() const { return m_entries; } + +void CSwordLexiconModuleInfo::testForStrongsKeys() { + auto & m = module(); + m.setPosition(sword::TOP); + m.increment(); + QString key = QString::fromUtf8(m.getKeyText()); + QRegExp rx1("[GH][0-9]+"); + if (rx1.exactMatch(key)) { + m_hasStrongsKeys = true; + m_hasLeadingStrongsLetter = true; + m_strongsDigitsLength = key.length() - 1; + } else { + QRegExp rx2("[0-9]+"); + if (rx2.exactMatch(key)) { + m_hasStrongsKeys = true; + m_strongsDigitsLength = key.length(); + } + } + return; +} + +bool CSwordLexiconModuleInfo:: hasStrongsKeys() const { + return m_hasStrongsKeys; +} + +QString CSwordLexiconModuleInfo::normalizeStrongsKey(const QString &key) const { + + QRegExp rx("([GH]*)([0-9]+)"); + if (! rx.exactMatch(key)) + return key; + QString StrongsChar = rx.cap(1); + QString digits = rx.cap(2); + + while (digits.length() < m_strongsDigitsLength) + digits = "0" +digits; + QString newKey = digits; + if (m_hasLeadingStrongsLetter) + newKey = StrongsChar + digits; + return newKey; +} + diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h index bd69dcc..cffc2ba 100644 --- a/src/backend/drivers/cswordlexiconmoduleinfo.h +++ b/src/backend/drivers/cswordlexiconmoduleinfo.h @@ -26,7 +26,23 @@ class CSwordLexiconModuleInfo: public CSwordModuleInfo { public: /* Methods: */ inline CSwordLexiconModuleInfo(sword::SWModule & module, CSwordBackend & backend) - : CSwordModuleInfo(module, backend, Lexicon) {} + : CSwordModuleInfo(module, backend, Lexicon), + m_hasStrongsKeys(false), + m_hasLeadingStrongsLetter(false), + m_strongsDigitsLength(0) { + testForStrongsKeys(); + } + + /** + Return true if this lexicon has Strong's keys + */ + bool hasStrongsKeys() const; + + /** + Takes a Strong's key string and formats it consistent + with the key strings of this module. + */ + QString normalizeStrongsKey(const QString& key) const; /** This method returns the entries of the modules represented by this @@ -46,6 +62,18 @@ class CSwordLexiconModuleInfo: public CSwordModuleInfo { } private: /* Fields: */ + + /** + See if module keys are consistent with Strong's references + and determine if keys start with "G" or "H" and the number + of digits in the keys. + */ + void testForStrongsKeys(); + + bool m_hasStrongsKeys; + bool m_hasLeadingStrongsLetter; + int m_strongsDigitsLength; + /** This is the list which caches the entres of the module. */ diff --git a/src/backend/filters/osistohtml.cpp b/src/backend/filters/osistohtml.cpp index bca5670..cd06275 100644 --- a/src/backend/filters/osistohtml.cpp +++ b/src/backend/filters/osistohtml.cpp @@ -78,6 +78,11 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor buf.append("<div class=\"chapter\" ></div>"); //don't open a div here, that would lead to a broken XML structure } else if (type == "x-p") { buf.append("<br/>"); + } else if (type == "paragraph") { + if (tag.getAttribute("sID")) + buf.append("<p>"); + else if (tag.getAttribute("eID")) + buf.append("</p>"); } else { buf.append("<div>"); } @@ -285,7 +290,6 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor myUserData->suspendTextPassThru = false; } } - // The <p> paragraph tag is handled by OSISHTMLHref else if (!strcmp(tag.getName(), "reference")) { // <reference> tag if (!tag.isEndTag() && !tag.isEmpty()) { @@ -417,9 +421,11 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor } } else if (!strcmp(tag.getName(), "p")) { - if (tag.isEmpty()) { - buf.append("<p/>"); - } + if (tag.isEndTag()) + buf.append("</p>"); + else + buf.append("<p>"); + } // <q> quote diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp index 5914336..bb080e5 100644 --- a/src/backend/managers/clanguagemgr.cpp +++ b/src/backend/managers/clanguagemgr.cpp @@ -1,3 +1,4 @@ + /********* * * This file is part of BibleTime's source code, http://www.bibletime.info/. @@ -415,7 +416,7 @@ void CLanguageMgr::init() { //: Language name pt m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) ); //: Language name pt_BR - m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself + m_langList.append( new Language("pt_BR", "Brazilian Portuguese", QObject::tr("Brazilian Portuguese")) );//added by ourself // m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) ); //: Language name qut m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) ); diff --git a/src/backend/rendering/btinforendering.cpp b/src/backend/rendering/btinforendering.cpp index c2e0efc..523022f 100644 --- a/src/backend/rendering/btinforendering.cpp +++ b/src/backend/rendering/btinforendering.cpp @@ -18,6 +18,7 @@ #include "../managers/cdisplaytemplatemgr.h" #include "../managers/referencemanager.h" #include "chtmlexportrendering.h" +#include "../drivers/cswordlexiconmoduleinfo.h" using namespace Rendering; @@ -380,7 +381,8 @@ QString decodeStrongs(QString const & data) { QString text; if (module) { QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module)); - key->setKey((*it).mid(1)); // skip H or G (language sign), will have to change later if we have better modules + auto lexModule = qobject_cast<CSwordLexiconModuleInfo*>(module); + key->setKey(lexModule->normalizeStrongsKey(*it)); text = key->renderedText(); } //if the module could not be found just display an empty lemma info diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp index f9802db..e504b83 100644 --- a/src/backend/rendering/chtmlexportrendering.cpp +++ b/src/backend/rendering/chtmlexportrendering.cpp @@ -116,7 +116,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k) .append("\""); } - if (key->isValid()) { + if (key->isValid() && i.key() == key->key()) { key_renderedText = key->renderedText(); // if key was expanded @@ -139,7 +139,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k) key_renderedText = "<span class=\"inactive\">—</span>"; } - if (m_filterOptions.headings) { + if (m_filterOptions.headings && key->isValid() && i.key() == key->key()) { // only process EntryAttributes, do not render, this might destroy the EntryAttributes again swModule.renderText(nullptr, -1, 0); @@ -190,7 +190,7 @@ QString CHTMLExportRendering::renderEntry(KeyTreeItem const & i, CSwordKey * k) entry.append(langAttr).append(isRTL ? " dir=\"rtl\">" : " dir=\"ltr\">"); //keys should normally be left-to-right, but this doesn't apply in all cases - if(key->isValid()) + if(key->isValid() && i.key() == key->key()) entry.append("<span class=\"entryname\" dir=\"ltr\">").append(entryLink(i, *mod_Itr)).append("</span>"); if (m_addText) |