15 #include <QRegularExpression>
16 #include <QRegularExpressionMatch>
19 #include "../../util/btassert.h"
20 #include "../drivers/cswordmoduleinfo.h"
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wextra-semi"
25 #pragma GCC diagnostic ignored "-Wsuggest-override"
26 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
28 #pragma clang diagnostic push
29 #pragma clang diagnostic ignored "-Wsuggest-destructor-override"
36 #pragma clang diagnostic pop
38 #pragma GCC diagnostic pop
43 QString
CSwordKey::normalizedKey()
const {
return key(); }
50 m.getKey()->setText(
rawKey() );
55 return QString::fromUtf8(m.getRawEntry());
62 if (
auto *
const vk_mod =
dynamic_cast<sword::VerseKey *
>(m.getKey()))
63 vk_mod->setIntros(
true);
65 m.getKey()->setText(
rawKey());
72 if (sword::stricmp(m.getKey()->getText(),
rawKey())
73 && !strstr(m.getKey()->getText(),
rawKey()))
75 qDebug(
"return an empty key for %s", m.getKey()->getText());
84 auto text = QString::fromUtf8(m.renderText(
nullptr, -1, DoRender).c_str());
90 const QString t(text);
91 static QRegularExpression
const rx(
92 QStringLiteral(R
"PCRE((GREEK|HEBREW) for 0*([1-9]\d*))PCRE"));
93 QRegularExpressionMatch match;
95 while ((pos = t.indexOf(rx, pos, &match)) != -1) {
96 auto language = match.captured(1);
97 auto langcode = language.at(0);
98 auto number = match.captured(2);
99 auto paddednumber = number.rightJustified(5,
'0');
104 R
"PCRE((>[^<>]+))PCRE"
105 R
"PCRE(\\b(0*%1)\\b)PCRE")
106 .arg(std::move(number))),
107 QStringLiteral(
"\\1<span lemma=\"%1%2\">"
108 "<a href=\"strongs://%3/%2\">\\2</a></span>")
109 .arg(std::move(langcode),
110 std::move(paddednumber),
111 std::move(language)));
112 pos += match.capturedLength();
123 m.getKey()->setText(std::string(
rawKey()).c_str());
125 return QString::fromUtf8(m.stripText());
virtual ~CSwordKey() noexcept
virtual const char * rawKey() const =0
const CSwordModuleInfo * m_module
QString renderedText(const CSwordKey::TextRenderType mode=CSwordKey::Normal)
@ ProcessEntryAttributesOnly
virtual QString key() const =0
virtual bool snap() const
sword::SWModule & swordModule() const