You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 13, 2020. It is now read-only.
This is a lua binding to the libcmark commonmark parser
(https://github.com/jgm/CommonMark). It requires that libcmark
be installed, and it also requires luajit.
This is work in progress. The idea is to use libcmark to do the
parsing, and provide pure lua writers and lua hooks for AST
manipulation. This way authors can easily customize the way
their text is rendered, and create renderers for new formats.
So far we have an xml writer (which prints an XML serialization of
the AST) and an html writer (which passes the CommonMark spec
tests).
Writers can easily be customized. For example, suppose you want
to render all regular text content uppercase, leaving code and
HTML tags alone:
#!/usr/bin/env luajitlocalcmark=require("commonmark")
localW=require("commonmark.writer.html")
localinp=io.read("*all")
localdoc=cmark.parse_document(inp, string.len(inp))
writer=W.new()
-- customize the writer:writer.text=function(node)
locals=cmark.node_get_string_content(node)
writer.out(writer.escape(s:upper()))
endio.write(writer.render(doc))
forwarninginwriter.warnings() doprint('WARNING', warning)
end
Alternatively, you could walk the AST, changing text content to
uppercase, and use the faster libcmark HTML renderer: