lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I'll look into releasing on luaforge.  The project needs some polishing
> first, e.g. better error handling and documentation.

It can always be made better, but please don't let this stop you from
making a release.

> No, currently you'd have to modify the module code. In the definition
> of 'parser' in markdown_parser.lua, you'd add a clause for your new
> pattern: something like
>
> MyPattern = p"[[" * lpeg.Ct((_"Inline" - p"]]")^0) * p"]]" / writer.mypattern

If this is the only thing that needs to be done, shouldn't it be easy
to expose the table that is used to create the parser, to allow adding
a pattern by simply setting a field? Perhaps something like:

    require("lunamark")
    require("lpeg")
    local wikilink_handler = function(s) return {"<span>", s, "</span>"} end
    my_parser = lunamark.parsers.markdown() -- or something similar
    my_parser.WikiLink = lpeg.P"[[" * lpeg.Ct((_"Inline" -
lpeg.P"]]")^0) * lpeg.P"]]" / wikilink_handler
    local converter = lunamark.converter(my_parser, "html")

> Then you'd add a mypattern function to the table returned by 'writer' in
> html_writer.lua (and any other writers you plan to use). This is your
> callback.

Is there any reason why this function should be inserted into the
module? It seems to work fine with just adding a local handler
function to the pattern.

- yuri