17#include "../config/btconfig.h"
18#include "../drivers/cswordmoduleinfo.h"
19#include "../managers/cswordbackend.h"
20#include "../managers/referencemanager.h"
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
31#pragma GCC diagnostic pop
38 :
sword::TEIHTMLHREF()
40 setPassThruUnknownEscapeString(
true);
44 sword::BasicFilterUserData *userData)
46 using namespace std::literals;
49 if (!substituteToken(buf, token)) {
51 sword::XMLTag
const tag(token);
52 std::string_view
const tagName(tag.getName());
54 if (tagName ==
"ref"sv) {
56 if (!tag.isEndTag() && !tag.isEmpty()) {
58 const char * attribute = tag.getAttribute(
"osisRef");
59 if (attribute !=
nullptr)
62 attribute = tag.getAttribute(
"target");
67 else if (tag.isEndTag()) {
74 else if (tagName ==
"hi"sv) {
75 const sword::SWBuf type = tag.getAttribute(
"rend");
77 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
79 buf.append(
"<span class=\"bold\">");
81 else if (type ==
"illuminated") {
82 buf.append(
"<span class=\"illuminated\">");
84 else if (type ==
"italic") {
85 buf.append(
"<span class=\"italic\">");
87 else if (type ==
"line-through") {
88 buf.append(
"<span class=\"line-through\">");
90 else if (type ==
"normal") {
91 buf.append(
"<span class=\"normal\">");
93 else if (type ==
"small-caps") {
94 buf.append(
"<span class=\"small-caps\">");
96 else if (type ==
"underline") {
97 buf.append(
"<span class=\"underline\">");
100 buf.append(
"<span>");
103 else if (tag.isEndTag()) {
104 buf.append(
"</span>");
108 return sword::TEIHTMLHREF::handleToken(buf, token, userData);
116 sword::BasicFilterUserData *myUserData)
119 if (QString ref = osisRef; !ref.isEmpty()) {
128 if (
auto const pos = ref.indexOf(
':');
130 && (pos < ref.size() - 1)
131 && ref.at(pos - 1).isLetter()
132 && ref.at(pos + 1).isLetter())
134 hrefRef = ref.mid(pos + 1);
138 QStringLiteral(
"standardBible"));
142 QStringLiteral(
"standardBible"));
151 QString::fromUtf8(myUserData->key->getText()),
154 buf.append(
"<a href=\"")
159 ).toUtf8().constData()
161 .append(
"\" crossrefs=\"")
171 sword::BasicFilterUserData *myUserData)
173 if (QString ref = osisRef; !ref.isEmpty()) {
182 if (
auto const pos = ref.indexOf(
':'); pos >= 0) {
183 QString newModuleName = ref.left(pos);
184 ref.remove(0, pos + 1);
186 mod = backend.findModuleByName(newModuleName);
188 mod = backend.findModuleByName(myUserData->module->getName());
190 mod = backend.findModuleByName(myUserData->module->getName());
196 QString::fromUtf8(myUserData->key->getText()),
199 buf.append(
"<a class=\"crossreference\" href=\"")
203 ref.toUtf8().constData()
204 ).toUtf8().constData()
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
CSwordModuleInfo * getDefaultSwordModuleByType(const QString &moduleType)
Returns default sword module info class for a given module type.
CSwordModuleInfo * findFirstAvailableModule(CSwordModuleInfo::ModuleType type)
CSwordModuleInfo * findModuleByName(const QString &name) const
Searches for a module with the given name.
static CSwordBackend & instance() noexcept
QString const & name() const
sword::SWModule & swordModule() const
void renderTargetReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData)
void renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData)
bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) override
QString parseVerseReference(QString const &ref, ParseOptions const &options)
QString encodeHyperlink(CSwordModuleInfo const &module, QString const &key)