[Sputnik-list] Markdown Extra in Lua: temporary solution
Yuri Takhteyev
yuri at sims.berkeley.edu
Mon Mar 17 20:51:49 GMT+2 2008
Note that if you want to use this in Sputnik, you can put this into a
module that mimics the behavior of sputnik.markup.markdown (basically
returning a table that provides a "transform" function), and then just
set a config parameter MARKUP_MODULE to the name of the module.
Though, I am wondering if there is a way to make Lua speak to PHP
without having to do disk IO.
- yuri
On Mon, Mar 17, 2008 at 12:28 PM, Bert Fitié <bert at analytag.com> wrote:
>
> I'm planning to use markdown within the framework of Kepler. Many of
> my markdown files contain tables following the syntax of PHP Markdown
> Extra. Extending the native markdown.lua with these extra features is
> at present not scheduled.
>
> Since I want to start with markdown in Kepler now, I am using the
> following temporary solution for Markdown Extra in Kepler:
>
> (1) First, the following PHP command line script "markdown-extra" in
> my PATH (from http://comox.textdrive.com/pipermail/textmate/2007-August/021803.html)
> :
>
> #!/usr/bin/php -q
>
> <?php
> include_once "/path/to/markdown-extra.php";
> $my_text = "";
> while (!feof(STDIN)) {
> $my_text .= fread(STDIN, 4096);
> }
> $my_html = Markdown($my_text);
> echo $my_html;
> ?>
>
> (2) Second, the following Lua function "markdown" in my private "util"
> module:
>
> function markdown(text)
> local input = os.tmpname()
> local output = os.tmpname()
> local f = assert(io.open(input, "w"))
> f:write(text)
> f:close()
> os.execute("markdown-extra < "..input.." >"..output)
> for line in io.lines (output) do
> cgilua.put (line)
> end
> os.remove (input)
> os.remove (output)
> end
>
> (3) Third, the following usage in Lua Pages (or Lua Scripts):
>
> <%
> require("util")
> local md = [=[
> <markdown text>
> ]=]
> %>
>
> <%= util.markdown(md) %>
>
> -- Bert
>
> _______________________________________________
> Sputnik-list mailing list
> Sputnik-list at lists.luaforge.net
> http://lists.luaforge.net/cgi-bin/mailman/listinfo/sputnik-list
>
--
http://sputnik.freewisdom.org/
More information about the Sputnik-list
mailing list