Cmark (cmark v0.10.0) View Source
Converts Markdown to supported target formats.
All functions below support the following options:
:sourcepos
- Include adata-sourcepos
attribute on all block elements.:hardbreaks
Rendersoftbreak
elements as hard line breaks.:nobreaks
Rendersoftbreak
elements as spaces.:normalize
Normalize tree by consolidating adjacent text nodes.:smart
Convert straight quotes to curly, --- to em dashes, -- to en dashes.:validate_utf8
Validate UTF-8 in the input before parsing, replacing illegal sequences with the replacement character U+FFFD.:unsafe
Allow raw HTML and unsafe links (javascript:
,vbscript:
,file:
, anddata:
, except forimage/png
,image/gif
,image/jpeg
, orimage/webp
mime types). The default is to treat everything as unsafe, which replaces invalid nodes by a placeholder HTML comment and unsafe links by empty strings.
Link to this section Summary
Types
A list of atoms describing the options to use (see module docs)
Functions
Converts the Markdown document to Commonmark.
Converts the Markdown document to HTML.
Converts the Markdown document to LaTeX.
Converts the Markdown document to Manpage.
Converts the Markdown document to XML.
Link to this section Types
Specs
options_list() :: [ :sourcepos | :hardbreaks | :nobreaks | :normalize | :validate_utf8 | :smart | :unsafe ]
A list of atoms describing the options to use (see module docs)
Link to this section Functions
Specs
to_commonmark(String.t(), options_list()) :: String.t()
Converts the Markdown document to Commonmark.
See Cmark
module docs for all options.
Examples
iex> Cmark.to_commonmark("test")
"test\n"
Specs
to_html(String.t(), options_list()) :: String.t()
Converts the Markdown document to HTML.
See Cmark
module docs for all options.
Examples
iex> Cmark.to_html("test")
"<p>test</p>\n"
Specs
to_latex(String.t(), options_list()) :: String.t()
Converts the Markdown document to LaTeX.
See Cmark
module docs for all options.
Examples
iex> Cmark.to_latex("test")
"test\n"
Specs
to_man(String.t(), options_list()) :: String.t()
Converts the Markdown document to Manpage.
See Cmark
module docs for all options.
Examples
iex> Cmark.to_man("test")
".PP\ntest\n"
Specs
to_xml(String.t(), options_list()) :: String.t()
Converts the Markdown document to XML.
See Cmark
module docs for all options.
Examples
iex> Cmark.to_xml("test")
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n <paragraph>\n <text xml:space=\"preserve\">test</text>\n </paragraph>\n</document>\n"