Initial support for sending markdown formatted messages

fixes #283
This commit is contained in:
Konstantinos Sideris 2018-09-07 20:05:30 +03:00
parent a21db789e7
commit 9e8f0b7409
7 changed files with 84 additions and 7 deletions

View file

@ -3,10 +3,12 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QSettings>
#include <QTextDocument>
#include <QXmlStreamReader>
#include <cmath>
#include <boost/variant.hpp>
#include <maddy/parser.h>
#include "Config.h"
@ -327,3 +329,24 @@ utils::linkifyMessage(const QString &body)
return textString;
}
std::string
utils::markdownToHtml(const std::string &text)
{
std::stringstream markdownInput(text);
auto parser = std::make_shared<maddy::Parser>();
return parser->Parse(markdownInput);
}
std::string
utils::markdownToHtml(const QString &text)
{
return markdownToHtml(text.toStdString());
}
std::string
utils::stripHtml(const std::string &text)
{
return QString::fromStdString(text).remove(QRegExp("<[^>]*>")).toStdString();
}