Top Documents Download Gallery Repository
Are you looking for a Software Engineer? Check Here

31markdown Module

The markdown module provides measures to parse a text formatted in markdown syntax. To utilize it, import the markdown module using import function.

Below is an example to read a document written in Markdown format and then render its HTML text into a file.


markdown module consists of the following two module files:


markdown.document << function

31.2markdown.document Class

The markdown.document class provides measures to parse a document written in Markdown format.

You can parse documents written in both string and stream using the following methods:

You can get the parsed result by inspecting a property markdown.document#root and its children that are markdown.item instances.


Property Type R/W Explanation
refs iterator R An iterator that returns referee items as markdown.item.
root markdown.item R The root item of the parsed Markdown document.


markdown.document(stream?:stream:r) {block?}
Returns an instance of markdown.document. If stream is specified, the content of the instance shall be initialized with the result of parsing the stream.


Parses a Markdown text in a string.

Parses a Markdown text from a stream.

markdown.document#render@console(colorFlag:boolean => true)
Renders the content of markdown document to the console.

In default, it uses colors to highlight items. Specify the argument colorFlag with false to disable the coloring process.

markdown.document#render@html(out?:stream:w, easyFormatFlag:boolean => true, captionIndex:boolean => false)
markdown.document#render@toc() {block}

31.3markdown.item Class

The markdown.item class provides information about items that composes a Markdown document.

Below is a table of item type:

Item Type Explanation
root container
h1 container
h2 container
h3 container
h4 container
h5 container
h6 container
p container
blockquote container
em container
strong container
codeblock container
ol container
ul container
li container
line container
a container
img text
text text
code text
entity text
tag container/text
hr no-content
br no-content
referee no-content


Property Type R/W Explanation
type string R
text string R
children iterator R
url string R
title string R
attrs string R
align symbol R none, left, center, right


Prints structured content of the item. Argument indent specifies an indentation level and is set to zero when omitted.

Copyright (C) 2011-2017 ypsitau