191 const QString &highlightKey,
195 if (lowerBound == upperBound)
203 auto curKey = lowerBound;
206 settings.
highlight = (!highlightKey.isEmpty() ? (curKey.key() == highlightKey) :
false);
214 if (curKey.chapter() == 0) {
216 tree.emplace_back(curKey.key(), modules, settings);
217 curKey.setChapter(1);
220 tree.emplace_back(curKey.key(), modules, settings);
221 if (!curKey.next()) {
225 }
while (curKey < upperBound);
243 ? QStringLiteral(
"<div class=\"currententry\">")
244 : QStringLiteral(
"<div class=\"entry\">");
252 if (modules.count() == 1)
255 QStringLiteral(
"dir=\"%1\" ")
256 .arg(modules.first()->textDirectionAsHtml()));
258 for (
auto const & item : tree)
262 ret.append(QStringLiteral(
"</div>"));
268 if (modules.isEmpty())
271 std::unique_ptr<CSwordKey> scoped_key(
272 !k ? modules.first()->createKey() :
nullptr);
273 CSwordKey *
const key = k ? k : scoped_key.get();
280 bool const oneModule = modules.size() == 1;
281 auto renderedText(oneModule
282 ? QStringLiteral(
"\n")
283 : QStringLiteral(
"\n\t\t<tr>\n"));
286 for (
auto const & modulePtr : modules) {
289 key->setModule(*modules.begin());
290 key->setKey(i.
key());
293 key->setModule(modulePtr);
295 key->setModule(modulePtr);
296 key->setKey(i.
key());
302 auto & swModule = modulePtr->swordModule();
303 auto const langAttr =
304 QStringLiteral(
" xml:lang=\"%1\" lang=\"%1\"").arg(
305 modulePtr->language()->abbrev());
307 QString key_renderedText;
308 if (key->isValid() && i.
key() == key->key()) {
309 key_renderedText = key->renderedText();
315 if (vk->isBoundSet()) {
317 auto const lowerBoundIndex = vk->lowerBound().index();
318 auto const upperBoundIndex = vk->upperBound().index();
319 for (
auto i = lowerBoundIndex; i < upperBoundIndex; ++i) {
320 key_renderedText +=
' ';
328 QStringLiteral(
"<span class=\"inactive\">—</span>");
335 swModule.renderText(
nullptr, -1, 0);
338 : swModule.getEntryAttributes()[
"Heading"][
"Preverse"])
340 auto preverseHeading(QString::fromUtf8(vp.second.c_str()));
341 if (preverseHeading.isEmpty())
344 static QString
const greaterOrS(
345 QStringLiteral(
">\x20\x09\x0d\x0a"));
346 for (
auto i = preverseHeading.indexOf(
'<');
348 i = preverseHeading.indexOf(
'<', i))
350 auto ref = QStringView(preverseHeading).mid(i + 1);
351 if (ref.startsWith(QStringLiteral(
"title"))) {
353 if (!ref.isEmpty() && greaterOrS.contains(ref[0])) {
354 auto const charsUntilTagEnd = ref.indexOf(
'>');
355 if (charsUntilTagEnd < 0)
358 preverseHeading.remove(i, charsUntilTagEnd + 7);
362 }
else if (ref.startsWith(QStringLiteral(
"/title"))) {
364 if (!ref.isEmpty() && greaterOrS.contains(ref[0])) {
365 auto const charsUntilTagEnd = ref.indexOf(
'>');
366 if (charsUntilTagEnd < 0)
369 preverseHeading.remove(i, charsUntilTagEnd + 8);
373 }
else if (ref.startsWith(QStringLiteral(
"div"))) {
375 if (!ref.isEmpty() && greaterOrS.contains(ref[0])) {
376 auto const charsUntilTagEnd = ref.indexOf(
'>');
377 if (charsUntilTagEnd < 0)
379 if (charsUntilTagEnd > 0) {
380 if (ref[charsUntilTagEnd - 1] ==
'/') {
382 preverseHeading.remove(
384 charsUntilTagEnd + 5);
386 i += charsUntilTagEnd + 5;
400 if (!preverseHeading.isEmpty())
401 entry = QStringLiteral(
402 "<div%1 class=\"sectiontitle\">%2</div>")
403 .arg(langAttr, preverseHeading);
408 ? QStringLiteral(
"<div class=\"")
409 : QStringLiteral(
"<div class=\"inline "));
411 entry.append(QStringLiteral(
"current"));
412 entry.append(QStringLiteral(
"entry\""));
413 auto const textDirectionAttribute =
414 QStringLiteral(
" dir=\"%1\">").arg(
415 modulePtr->textDirectionAsHtml());
416 entry.append(langAttr).append(textDirectionAttribute);
419 if(key->isValid() && i.
key() == key->key())
422 "<span class=\"entryname\" dir=\"ltr\">%1</span>")
426 entry.append(key_renderedText);
431 entry.append(QStringLiteral(
"</div>"));
434 renderedText.append(QStringLiteral(
"\t\t%1\n").arg(entry));
437 QStringLiteral(
"\t\t<td class=\"%1entry\"%2%3\n\t\t\t%4"
440 ? QStringLiteral(
"current")
443 textDirectionAttribute,
449 renderedText.append(QStringLiteral(
"\t\t</tr>\n"));