From 074608dec15e10a61decdcc017cc1927b99b8dc3 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Tue, 11 Sep 2018 14:56:09 +0300 Subject: Switch to libcmark --- src/Utils.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Utils.cpp b/src/Utils.cpp index 5d5508b6..6ac675d4 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include "Config.h" @@ -333,16 +333,21 @@ utils::linkifyMessage(const QString &body) std::string utils::markdownToHtml(const std::string &text) { - std::stringstream markdownInput(text); - auto parser = std::make_shared(); + const char *tmp_buf = cmark_markdown_to_html(text.c_str(), text.size(), CMARK_OPT_DEFAULT); - return parser->Parse(markdownInput); + // Copy the null terminated output buffer. + std::string html(tmp_buf); + + // The buffer is no longer needed. + free((char *)tmp_buf); + + return html; } std::string utils::markdownToHtml(const QString &text) { - return markdownToHtml(text.toStdString()); + return utils::markdownToHtml(text.toStdString()); } std::string -- cgit 1.5.1