Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Add space to empty anchor tags to fix internal links. #2957

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/lib/pdfconverter.cc
Expand Up @@ -546,13 +546,28 @@ void PdfConverterPrivate::findLinks(QWebFrame * frame, QVector<QPair<QWebElement
uexternal = PageObject::webPageToObject[frame->page()]->settings.useExternalLinks;
}
if (!ulocal && !uexternal) return;
foreach (const QWebElement & elm, frame->findAllElements("a")) {
foreach (QWebElement elm, frame->findAllElements("a")) {

QString id=elm.attribute("id");
if (id.isEmpty()) id=elm.attribute("ns0:id");
if (id.startsWith("__WKANCHOR_")) anchors[id] = elm;

QString n=elm.attribute("name");
if (n.isEmpty()) n=elm.attribute("ns0:name");
if (n.startsWith("__WKANCHOR_")) anchors[n] = elm;

QString h=elm.attribute("href");
if (h.isEmpty()) h=elm.attribute("ns0:href");

if (h.isEmpty() && (id.length() > 0 || n.length() > 0)) {
if (elm.firstChild().isNull()) {
elm.setStyleProperty("font-size","1px");
elm.setStyleProperty("height","0px");
elm.setStyleProperty("float","left");
elm.prependInside("&nbsp;");
}
}

if (h.startsWith("__WKANCHOR_")) {
local.push_back( qMakePair(elm, h) );
} else {
Expand Down