Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
Markdown

A growing implementation of Markdown-related utilities based on GitHub Flavored Markdown (GFM). More...

Functions

SOURCEMETA_CORE_MARKDOWN_EXPORT auto sourcemeta::core::markdown_to_html (const std::string_view input, const bool safe=true) -> std::string

Detailed Description

A growing implementation of Markdown-related utilities based on GitHub Flavored Markdown (GFM).

This functionality is included as follows:

#include <sourcemeta/core/markdown.h>

Function Documentation

◆ markdown_to_html()

SOURCEMETA_CORE_MARKDOWN_EXPORT auto sourcemeta::core::markdown_to_html ( const std::string_view input,
const bool safe = true ) -> std::string

Convert a Markdown string to an HTML fragment using GitHub Flavored Markdown (GFM) with all standard extensions enabled (tables, autolinks, strikethrough, tag filtering, and task lists). Raw HTML and dangerous links are suppressed by default, so the result is safe to render from untrusted input. Passing a false safe argument lets raw HTML and unsafe links pass through unchanged, which must only be done for trusted input. For example:

#include <sourcemeta/core/markdown.h>
#include <cassert>
const auto result{sourcemeta::core::markdown_to_html("Hello **world**")};
assert(result == "<p>Hello <strong>world</strong></p>\n");
SOURCEMETA_CORE_MARKDOWN_EXPORT auto markdown_to_html(const std::string_view input, const bool safe=true) -> std::string