summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2022-04-20 22:10:02 +0200
committerSlávek Banko <slavek.banko@axis.cz>2022-04-21 15:29:53 +0200
commit13ac5ec61834960ec27d457cf5bef5ba0849a681 (patch)
treebb332cee82e043083f41ebf1648d14c8abc73314
parentad682c23845d1ad1ead5de7537e7b64cd1e8daf0 (diff)
downloadtdelibs-13ac5ec61834960ec27d457cf5bef5ba0849a681.tar.gz
tdelibs-13ac5ec61834960ec27d457cf5bef5ba0849a681.zip
TDEMarkdown: Use the file name as the document title.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit ab35068aaddf7570706a1dc8538a0775e3c81790)
-rw-r--r--tdemarkdown/markdown_part.cpp6
-rw-r--r--tdemarkdown/markdown_part.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/tdemarkdown/markdown_part.cpp b/tdemarkdown/markdown_part.cpp
index 7ea3d99b1..255ed7280 100644
--- a/tdemarkdown/markdown_part.cpp
+++ b/tdemarkdown/markdown_part.cpp
@@ -79,7 +79,7 @@ bool MarkdownPart::openURL(const KURL& u)
data[data.size()-1] = '\0';
}
begin(u);
- TQString parsed(parse((MD_CHAR*) data.data()));
+ TQString parsed(parse((MD_CHAR*) data.data(), u.fileName().utf8().data()));
write(parsed);
end();
}
@@ -89,13 +89,13 @@ bool MarkdownPart::openURL(const KURL& u)
return true;
}
-TQString& MarkdownPart::parse(MD_CHAR* document)
+TQString& MarkdownPart::parse(MD_CHAR* document, MD_CHAR* title)
{
m_buffer = "<!DOCTYPE html>\n";
m_buffer += "<html>\n";
m_buffer += " <head>\n";
m_buffer += " <meta charset='utf-8'>\n";
- m_buffer += " <title>TODO</title>\n";
+ m_buffer += " <title>" + (title ? title : i18n("Markdown document")) + "</title>\n";
m_buffer += " </head>\n";
m_buffer += " <body>\n";
diff --git a/tdemarkdown/markdown_part.h b/tdemarkdown/markdown_part.h
index 0131553d3..f3e003ec9 100644
--- a/tdemarkdown/markdown_part.h
+++ b/tdemarkdown/markdown_part.h
@@ -34,7 +34,7 @@ class MarkdownPart : public TDEHTMLPart
bool openURL(const KURL& u);
/* Parser */
- TQString& parse(MD_CHAR* document);
+ TQString& parse(MD_CHAR* document, MD_CHAR* title = nullptr);
private:
TQString m_buffer;