Skip Navigation
Framework

GFMarkdown

Convert GitHub Flavored Markdown to HTML easily with the @Markdown property wrapper. Optionally customize every CMark option and GFM extension available.

Overview

Use this library to generate HTML from a string containing GitHub Flavored Markdown (GFM) / CommonMark content.

For example this code:

# Hello
Hello, _World_!

Will be translated into this code:

<h1>Hello</h1>
<p>Hello, <em>World<em>!</p>

Acknowledgements

This implementation is built entirely on top of the amazing cmark-gfm which itself is a fork of the excellent cmark.

Basic usage

Just tag your properties with the Markdown wrapper.

@Markdown var content = "# Hello"


// Automatic HTML conversion.
print(content) // "<h1>Hello</h1>"


// Retrieve the original Markdown.
print($content) // "# Hello"

Alternativelly wrap your Markdown string with MarkdownString and call toHTML(options:extensions:) with no parameters.

let html = GFMarkdown("# Hello").toHTML()
print(html) // "<h1>Hello</h1>"

Topics

Current page is GFMarkdown