mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-02-26 08:22:31 +00:00
common: add Markdown-to-HTML conversion wrapper around cmark
This commit is contained in:
parent
f700dfbd1e
commit
b0fa335b66
37
src/common/markdown.cpp
Normal file
37
src/common/markdown.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
mkvmerge -- utility for splicing together matroska files
|
||||||
|
from component media subtypes
|
||||||
|
|
||||||
|
Distributed under the GPL v2
|
||||||
|
see the file COPYING for details
|
||||||
|
or visit http://www.gnu.org/copyleft/gpl.html
|
||||||
|
|
||||||
|
Written by Moritz Bunkus <moritz@bunkus.org>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/common_pch.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_CMARK)
|
||||||
|
|
||||||
|
# include <cmark.h>
|
||||||
|
|
||||||
|
# include "common/markdown.h"
|
||||||
|
|
||||||
|
namespace mtx { namespace markdown {
|
||||||
|
|
||||||
|
std::string
|
||||||
|
to_html(std::string const &markdown_text,
|
||||||
|
int options) {
|
||||||
|
auto html = cmark_markdown_to_html(markdown_text.c_str(), markdown_text.length(), options);
|
||||||
|
if (!html)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
auto html_str = std::string{html};
|
||||||
|
free(html);
|
||||||
|
|
||||||
|
return html_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // defined(HAVE_CMARK)
|
24
src/common/markdown.h
Normal file
24
src/common/markdown.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
mkvmerge -- utility for splicing together matroska files
|
||||||
|
from component media subtypes
|
||||||
|
|
||||||
|
Distributed under the GPL v2
|
||||||
|
see the file COPYING for details
|
||||||
|
or visit http://www.gnu.org/copyleft/gpl.html
|
||||||
|
|
||||||
|
Written by Moritz Bunkus <moritz@bunkus.org>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_pch.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_CMARK)
|
||||||
|
|
||||||
|
namespace mtx { namespace markdown {
|
||||||
|
|
||||||
|
std::string to_html(std::string const &markdown_text, int options = 0);
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // defined(HAVE_CMARK)
|
Loading…
Reference in New Issue
Block a user