16 #include <string_view>
17 #include "../config/btconfig.h"
18 #include "../drivers/cswordmoduleinfo.h"
19 #include "../managers/cswordbackend.h"
20 #include "../managers/referencemanager.h"
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
28 #pragma GCC diagnostic pop
34 :
sword::TEIHTMLHREF()
36 setPassThruUnknownEscapeString(
true);
40 sword::BasicFilterUserData *userData)
42 using namespace std::literals;
45 if (!substituteToken(buf, token)) {
47 sword::XMLTag
const tag(token);
48 std::string_view
const tagName(tag.getName());
50 if (tagName ==
"ref"sv) {
52 if (!tag.isEndTag() && !tag.isEmpty()) {
54 const char * attribute = tag.getAttribute(
"osisRef");
55 if (attribute !=
nullptr)
58 attribute = tag.getAttribute(
"target");
63 else if (tag.isEndTag()) {
70 else if (tagName ==
"hi"sv) {
71 const sword::SWBuf type = tag.getAttribute(
"rend");
73 if ((!tag.isEndTag()) && (!tag.isEmpty())) {
75 buf.append(
"<span class=\"bold\">");
77 else if (type ==
"illuminated") {
78 buf.append(
"<span class=\"illuminated\">");
80 else if (type ==
"italic") {
81 buf.append(
"<span class=\"italic\">");
83 else if (type ==
"line-through") {
84 buf.append(
"<span class=\"line-through\">");
86 else if (type ==
"normal") {
87 buf.append(
"<span class=\"normal\">");
89 else if (type ==
"small-caps") {
90 buf.append(
"<span class=\"small-caps\">");
92 else if (type ==
"underline") {
93 buf.append(
"<span class=\"underline\">");
99 else if (tag.isEndTag()) {
100 buf.append(
"</span>");
104 return sword::TEIHTMLHREF::handleToken(buf, token, userData);
112 sword::BasicFilterUserData *myUserData)
115 if (QString ref = osisRef; !ref.isEmpty()) {
124 if (
auto const pos = ref.indexOf(
':');
126 && (pos < ref.size() - 1)
127 && ref.at(pos - 1).isLetter()
128 && ref.at(pos + 1).isLetter())
130 hrefRef = ref.mid(pos + 1);
134 QStringLiteral(
"standardBible"));
138 QStringLiteral(
"standardBible"));
147 QString::fromUtf8(myUserData->key->getText()),
150 buf.append(
"<a href=\"")
155 ).toUtf8().constData()
157 .append(
"\" crossrefs=\"")
167 sword::BasicFilterUserData *myUserData)
169 if (QString ref = osisRef; !ref.isEmpty()) {
178 if (
auto const pos = ref.indexOf(
':'); pos >= 0) {
179 QString newModuleName = ref.left(pos);
180 ref.remove(0, pos + 1);
182 mod =
backend.findModuleByName(newModuleName);
184 mod =
backend.findModuleByName(myUserData->module->getName());
186 mod =
backend.findModuleByName(myUserData->module->getName());
192 QString::fromUtf8(myUserData->key->getText()),
195 buf.append(
"<a class=\"crossreference\" href=\"")
199 ref.toUtf8().constData()
200 ).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
std::unique_ptr< CSwordBackend > backend(sword::InstallSource const &is)
QString parseVerseReference(QString const &ref, ParseOptions const &options)
QString encodeHyperlink(CSwordModuleInfo const &module, QString const &key)