ztcl::markdown
Reads Markdown (CommonMark 0.31.2 with the GFM extensions) and gives its HTML, its events, or its tree.
ztcl::markdown SUBCOMMAND ?ARG ...?
Description
The commands of the Markdown reader. The syntax is CommonMark 0.31.2 with the extensions of GitHub Flavored Markdown: tables, task lists, strike text, extended autolinks, and the filter of raw HTML tags. html gives the HTML, events gives a flat list of the blocks and the inlines with their byte ranges in the source, and tree gives the same data as nested lists.
Load the module with package require ztcl::markdown. It needs no capability, and its output depends only on its arguments. Each subcommand is also the command ztcl::markdown::NAME, such as ztcl::markdown::html, and a unique prefix of a subcommand is the subcommand.
A read counts in the memory limit, and it stops with the error ZTCL MARKDOWN NESTING when the blocks or the inlines nest deeper than the nesting limit of scripts.
Subcommands
| Subcommand | Description |
|---|---|
ztcl::markdown html | Gives the HTML of a Markdown text. |
ztcl::markdown events | Gives the blocks and the inlines of a Markdown text as a flat list of events. |
ztcl::markdown tree | Gives the blocks and the inlines of a Markdown text as nested lists. |
Returns
The result of the subcommand.
Examples
Each example of this page runs after package require ztcl::markdown.
% ztcl::markdown html "# Launch"
<h1>Launch</h1>
% llength [ztcl::markdown events "*a*"]
7
Errors
% ztcl::markdown bogus
unknown or ambiguous subcommand "bogus": must be events, html, or tree
-errorcode TCL LOOKUP SUBCOMMAND bogus
% ztcl::markdown
wrong # args: should be "ztcl::markdown subcommand ?arg ...?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.8
- Compute cost
- One compute unit for each 256 bytes of the text in each of the two passes, and one for each step of the work of the delimiters and the brackets.
The full page: ztcl::markdown.