[ANN] markdown.lua 0.10

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] markdown.lua 0.10

Niklas Frykholm-2
# markdown.lua -- version 0.10

<http://www.frykholm.se/files/markdown.lua>

**Author:** Niklas Frykholm, <[hidden email]>  
**Date:** 3 May 2006

This is an implementation of the popular text markup language Markdown
in pure Lua.
Markdown can convert documents written in a simple and easy to read text
format
to well-formatted HTML. For a more thourough description of Markdown and
the Markdown
syntax, see <http://daringfireball.net/projects/markdown>.

The original Markdown source is written in Perl and makes heavy use of
advanced
regular expression techniques (such as negative look-ahead, etc) which
are not available
in Lua's simple regex engine. Therefore this Lua port has been rewritten
from the ground
up. It is probably not completely bug free. If you notice any bugs,
please report them to
me. A unit test that exposes the error is helpful.

## Usage

    require "markdown"
    markdown(source)

``markdown.lua`` exposes a single global function named ``markdown(s)``
which applies the
Markdown transformation to the specified string.

``markdown.lua`` can also be used directly from the command line:

    lua markdown.lua test.md

Creates a file ``test.html`` with the converted content of ``test.md``. Run:

    lua markdown.lua -h

For a description of the command-line options.

// Niklas


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Edwin Eyan Moragas-2
On 5/11/06, Niklas Frykholm <[hidden email]> wrote:
> # markdown.lua -- version 0.10
>
> <http://www.frykholm.se/files/markdown.lua>


many thanks for this.

--
salud,
eyan

http://www.eyan.org
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Petite Abeille
In reply to this post by Niklas Frykholm-2

On May 11, 2006, at 11:28, Niklas Frykholm wrote:

> This is an implementation of the popular text markup language Markdown
> in pure Lua.

Excellent! Will fit right in LUPad :))

http://alt.textdrive.com/lua/23/lua-lupad

Many thanks!

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Alex Queiroz
In reply to this post by Niklas Frykholm-2
Hallo,

On 5/11/06, Niklas Frykholm <[hidden email]> wrote:
>
> This is an implementation of the popular text markup language Markdown
> in pure Lua.
> Markdown can convert documents written in a simple and easy to read text
> format
> to well-formatted HTML. For a more thourough description of Markdown and
> the Markdown
> syntax, see <http://daringfireball.net/projects/markdown>.
>

     That's cool, could be used as the formatter of my wiki. But, what
are the licensing terms?

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Niklas Frykholm-2

>>
>> This is an implementation of the popular text markup language Markdown
>> in pure Lua.
>> Markdown can convert documents written in a simple and easy to read text
>> format
>> to well-formatted HTML. For a more thourough description of Markdown and
>> the Markdown
>> syntax, see <http://daringfireball.net/projects/markdown>.
>>
>   That's cool, could be used as the formatter of my wiki. But, what
> are the licensing terms?
>
Ah, I forgot to add that. You can use it under the same license as Lua.

// Niklas
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Petite Abeille
In reply to this post by Alex Queiroz

On May 11, 2006, at 13:59, Alex Queiroz wrote:

>     That's cool, could be used as the formatter of my wiki.

By the way, is the source code for your wiki still available somewhere?
I somehow remember you mentioning it sometime ago, but I cannot track
it down anymore...

TIA!

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Alex Queiroz
In reply to this post by Niklas Frykholm-2
Hallo,

On 5/11/06, Niklas Frykholm <[hidden email]> wrote:
>
> This is an implementation of the popular text markup language Markdown
> in pure Lua.
> Markdown can convert documents written in a simple and easy to read text
> format
> to well-formatted HTML. For a more thourough description of Markdown and
> the Markdown
> syntax, see <http://daringfireball.net/projects/markdown>.
>

-- Joins an array into text separated by separator
function join(arr, sep)
        if #arr == 0 then return "" end
        local res = arr[1]
        for i = 2,#arr do
                res = res .. sep .. arr[i]
        end
        return res
end

     Why do you use this instead of table.concat? Since strings are
immutable, this code can use a lot of memory, as explained in PiL.

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Alex Queiroz
In reply to this post by Petite Abeille
Hallo,

On 5/11/06, PA <[hidden email]> wrote:
>
> On May 11, 2006, at 13:59, Alex Queiroz wrote:
>
> >     That's cool, could be used as the formatter of my wiki.
>
> By the way, is the source code for your wiki still available somewhere?
> I somehow remember you mentioning it sometime ago, but I cannot track
> it down anymore...
>

     Well, it's live at http://www.ventonegro.org/iara/. But as it's a
bit ambitious (the wiki is a part of the whole), the parser and
formatter are very hackish and need attention. The CSS styling could
use some help, too.
     It's all Lua apart of a simple sqlite3 binding I've written. Drop
me a line if you want the source code.

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] markdown.lua 0.10

Niklas Frykholm-2
In reply to this post by Alex Queiroz

> -- Joins an array into text separated by separator
> function join(arr, sep)
>     if #arr == 0 then return "" end
>     local res = arr[1]
>     for i = 2,#arr do
>         res = res .. sep .. arr[i]
>     end
>     return res
> end
>
>     Why do you use this instead of table.concat? Since strings are
> immutable, this code can use a lot of memory, as explained in PiL.

Sloppy reading of the documentation. I somehow missed table.concat. I'll
make a new release tomorrow that fixes this and any other problems that
are found until then.

Overall, markdown.lua is pretty slow as parsers go. It makes a lot of
passes over the source file, substituting different things in each pass.
(markdown.pl works the same way.)

// Niklas