func

markdown_to_html

cmarkwrapper.func.markdown_to_html(text, breaks=False, safe=True, sourcepos=False, smart=Option.OPT_SMART)

Convert markup to HTML.

参数
  • text (str) -- Text marked up with CommonMark.

  • breaks (Union[bool, cmarkwrapper.types.LineBreaks]) -- bool or LineBreaks How line breaks in text will be rendered. If True, "soft", or LineBreaks.soft -- as newlines (\n). If False -- as spaces. If "hard" or LineBreaks.hard -- as <br />s.

  • safe (bool) -- When True, replace raw HTML (that was present in text)with HTML comment.

  • sourcepos (bool) -- If True, add data-sourcepos attribute to block elements(that is, use CMARK_OPT_SOURCEPOS).

  • smart (cmarkwrapper.types.Option) -- Use OPT_SMART.

返回

HTML string.

返回类型

str

markdown_to_xml

cmarkwrapper.func.markdown_to_xml(text, sourcepos=False, smart=Option.OPT_SMART)

Convert markup to XML.

参数
  • text (str) --

    Text marked up with CommonMark.

  • sourcepos (bool) -- If True, add sourcepos attribute to all block elements(that is, use CMARK_OPT_SOURCEPOS).

  • smart (cmarkwrapper.types.Option) -- Use OPT_SMART.

返回

XML string.

返回类型

str

markdown_to_commonmark

cmarkwrapper.func.markdown_to_commonmark(text, breaks=False, width=0, smart=Option.OPT_SMART)

Convert markup to CommonMark.

参数
  • text (str) --

    Text marked up with CommonMark.

  • breaks (Union[bool, cmarkwrapper.types.LineBreaks]) -- bool or LineBreaks How line breaks will be rendered. If True, "soft", or LineBreaks.soft -- as newlines (\n). If False -- as spaces. If "hard" or LineBreaks.hard -- “soft break nodes” (single newlines) are rendered as two spaces and \n.

  • width (int) -- Wrap width of output by inserting line breaks (default is``0``—no wrapping). Has no effect if breaks are set to be``"hard"`` (e.g. with LineBreaks.hard).

  • smart (cmarkwrapper.types.Option) -- Use OPT_SMART.

返回

CommonMark string.

返回类型

str

markdown_to_man

cmarkwrapper.func.markdown_to_man(text, breaks=False, width=0, smart=Option.OPT_SMART)

Convert markup to groff man page.

参数
  • text (str) --

    Text marked up with CommonMark.

  • breaks (Union[bool, cmarkwrapper.types.LineBreaks]) -- bool or LineBreaks How line breaks will be rendered. If True, "soft", or LineBreaks.soft -- “soft break nodes” (single newlines) are rendered as newlines (\n). If False -- “soft break nodes” are rendered as spaces. If "hard" or LineBreaks.hard -- “soft break nodes” are rendered as .PD 0\n.P\n.PD\n.

  • width (int) -- Wrap width of output by inserting line breaks (default is``0``—no wrapping). Has no effect if breaks are False.

  • smart (cmarkwrapper.types.Option) -- Use OPT_SMART.

返回

Page without the header.

返回类型

str

markdown_to_latex

cmarkwrapper.func.markdown_to_latex(text, breaks=False, width=0, smart=Option.OPT_SMART)

Convert markup to LaTeX.

参数
  • text (str) --

    Text marked up with CommonMark.

  • breaks (Union[bool, cmarkwrapper.types.LineBreaks]) -- bool or LineBreaks How line breaks will be rendered. If True, "soft", or LineBreaks.soft -- as newlines. If False -- “soft break nodes” (single newlines) are rendered as spaces. If "hard" or LineBreaks.hard -- “soft break nodes” are rendered as \\\n.

  • width (int) -- Wrap width of output by inserting line breaks (default is 0—no wrapping). Has no effect if breaks are False.

  • smart (cmarkwrapper.types.Option) -- Use OPT_SMART.

返回

LaTeX document.

返回类型

str