TDEMarkdown: Use the file name as the document title.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/161/head
Slávek Banko 3 years ago
parent 819611b11b
commit ab35068aad
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -79,7 +79,7 @@ bool MarkdownPart::openURL(const KURL& u)
data[data.size()-1] = '\0'; data[data.size()-1] = '\0';
} }
begin(u); begin(u);
TQString parsed(parse((MD_CHAR*) data.data())); TQString parsed(parse((MD_CHAR*) data.data(), u.fileName().utf8().data()));
write(parsed); write(parsed);
end(); end();
} }
@ -89,13 +89,13 @@ bool MarkdownPart::openURL(const KURL& u)
return true; return true;
} }
TQString& MarkdownPart::parse(MD_CHAR* document) TQString& MarkdownPart::parse(MD_CHAR* document, MD_CHAR* title)
{ {
m_buffer = "<!DOCTYPE html>\n"; m_buffer = "<!DOCTYPE html>\n";
m_buffer += "<html>\n"; m_buffer += "<html>\n";
m_buffer += " <head>\n"; m_buffer += " <head>\n";
m_buffer += " <meta charset='utf-8'>\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 += " </head>\n";
m_buffer += " <body>\n"; m_buffer += " <body>\n";

@ -34,7 +34,7 @@ class MarkdownPart : public TDEHTMLPart
bool openURL(const KURL& u); bool openURL(const KURL& u);
/* Parser */ /* Parser */
TQString& parse(MD_CHAR* document); TQString& parse(MD_CHAR* document, MD_CHAR* title = nullptr);
private: private:
TQString m_buffer; TQString m_buffer;

Loading…
Cancel
Save