Markdown Library for haxe / haxelib (supports js, flash, php, neko and possibly more)

150 views
Skip to first unread message

Jason O'Neil

unread,
Apr 25, 2012, 2:12:29 PM4/25/12
to haxe...@googlegroups.com
Hi List

I've just submitted "mdown", a Markdown library for haxe, to haxelib. 

My library is based on whoever made this code: http://code.google.com/p/mdown/ , but I've added a bunch of unit tests and tested cross platform, which has resulted in a bunch of fixes. 

Target support is as follows:
  • Javascript - working reliably
  • Flash 9+ - working reliably
  • PHP - The library I forked from was working, I have not confirmed it with my changes.
  • Neko - mostly working, a few remaining issues to be sorted out.
  • Others - untested

You can install using: `haxelib install mdown`

And the usage is `var html = Markdown.convert('Hello **World**');`

Hope this is of use to some people!  Any bugs you notice please either reply or post an issue on Github: https://github.com/jasononeil/mdown

Jason

Franco Ponticelli

unread,
Apr 25, 2012, 2:53:23 PM4/25/12
to haxe...@googlegroups.com
Well done! A library I will use for sure at some point.

Franco

Justin Donaldson

unread,
Apr 25, 2012, 3:19:52 PM4/25/12
to haxe...@googlegroups.com
Yeah, thanks for this.  I'm not sure how it compares to Nicolas' wiki markup renderer, but markdown is a well known syntax, and another consistent client/server converter is always welcome.

Best,
-Justin

Nicolas Cannasse

unread,
Apr 25, 2012, 4:18:04 PM4/25/12
to haxe...@googlegroups.com
Le 25/04/2012 20:12, Jason O'Neil a �crit :
> Hi List
>
> I've just submitted "mdown", a Markdown library for haxe, to haxelib.
>
> My library is based on whoever made this code:
> http://code.google.com/p/mdown/ , but I've added a bunch of unit tests
> and tested cross platform, which has resulted in a bunch of fixes.

That's funny, I was talking yesterday about some people at Motion-Twin
about open sourcing the new markup formatter we wrote for twinoid.com

I'm not sure if it's compatible with Markdown, but it has the big
advantage of being a "real" parser, not a bunch of regexp, so it's
actually a lot faster to render big texts and cannot be exploited in
tricky ways to do HTML injection.

Also it's entirely customizable since you can customize how each BB-Code
block will be converted to HTML, so I was thinking adding it to haxe
standard library, if there is some interest for it ?

Best,
Nicolas

Franco Ponticelli

unread,
Apr 25, 2012, 4:19:48 PM4/25/12
to haxe...@googlegroups.com
There is certainly interest but why not releasing it simply on haxelib?

Franco

On Wed, Apr 25, 2012 at 2:18 PM, Nicolas Cannasse <ncan...@motion-twin.com> wrote:

Jason O'Neil

unread,
Apr 25, 2012, 8:40:26 PM4/25/12
to haxe...@googlegroups.com

Hi,

Thanks all for the encouragement.

Nicolas, if you have a parser that can be adapted I'm sure that's a much better solution and I'd be happy to add some rules to make it parse Markdown. I don't mind if it's in std or haxelib.

Jason

...

Sent from my phone, so apologies for any typos...

On Apr 26, 2012 4:18 AM, "Nicolas Cannasse" <ncan...@motion-twin.com> wrote:

Mike Stead

unread,
Apr 25, 2012, 11:19:56 PM4/25/12
to haxe...@googlegroups.com
Sounds great Nicolas, I'd be real interested if it was markdown compliant, otherwise not so much... unless it could be forked to be compliant.

Agree with Franco, would seem a haxelib makes more sense here.

P.S Nice work Jason, I've used that library in the past, good to have it on haxelib.

Marcelo de Moraes Serpa

unread,
Apr 25, 2012, 11:24:22 PM4/25/12
to haxe...@googlegroups.com
Nicolas, 

Of course there's interest. I'd be, specially in the parsing code. Share the source!

- Marcelo.

Benjamin Dubois

unread,
Apr 26, 2012, 2:07:03 AM4/26/12
to haxe...@googlegroups.com
Are you a kind of fairy ?

I was looking for a lightweight markup language only 2 hours before your post.

Thank you very much.

Ben

Jason O'Neil

unread,
Apr 26, 2012, 2:19:00 AM4/26/12
to haxe...@googlegroups.com
On Thu, Apr 26, 2012 at 2:07 PM, Benjamin Dubois <bubbl...@gmail.com> wrote:
Are you a kind of fairy ?

I hope not ;)

Nicolas Cannasse

unread,
Apr 26, 2012, 5:06:23 AM4/26/12
to haxe...@googlegroups.com
Le 26/04/2012 02:40, Jason O'Neil a �crit :
> Hi,
>
> Thanks all for the encouragement.
>
> Nicolas, if you have a parser that can be adapted I'm sure that's a much
> better solution and I'd be happy to add some rules to make it parse
> Markdown. I don't mind if it's in std or haxelib.

Ok I've put it up there so everybody interested can check it :
https://github.com/ncannasse/markaxe

Best,
Nicolas

Benjamin Dubois

unread,
Apr 26, 2012, 7:19:32 AM4/26/12
to haxe...@googlegroups.com
Interesting. why not putting it in haxelib ?

Ben

On Thu, Apr 26, 2012 at 11:06 AM, Nicolas Cannasse <ncan...@motion-twin.com> wrote:
Le 26/04/2012 02:40, Jason O'Neil a écrit :

Hi,

Thanks all for the encouragement.

Nicolas, if you have a parser that can be adapted I'm sure that's a much
better solution and I'd be happy to add some rules to make it parse
Markdown. I don't mind if it's in std or haxelib.

Ok I've put it up there so everybody interested can check it :
https://github.com/ncannasse/markaxe


Best,
Nicolas

Nicolas Cannasse

unread,
Apr 26, 2012, 7:52:06 AM4/26/12
to haxe...@googlegroups.com
Le 26/04/2012 13:19, Benjamin Dubois a �crit :
> Interesting. why not putting it in haxelib ?

a) not much time
b) better to have it there while people are playing with it

We will add it either to haxelib or haxe std library if there is an
interest for it.

Best,
Nicolas

Benjamin Dubois

unread,
Apr 26, 2012, 9:08:38 AM4/26/12
to haxe...@googlegroups.com
I've seen in the tests that it is possible to create span or div using 
[my_span_class] Content of my span [/my_span_class]
[my_div_class]\n Content of my div \n[/my_div_class]

will result in the following
<span class="my_span_class"> Content of my span </span>
<div class="my_div_class"> Content of my div </div>

my question is about that from the readme
[tag=attrib]...[/tab] : same but with an attribute (can be anything not including ] or newlines)
Does that me I can add attributes by nesting a tag inside like that :
[my_span_class] [my_span_class=id] my_span_id [/my_span_class] Content of my span [/my_span_class]

Am I right, or it is restricted to html tags and should be used like that
[img=src] /images/my_picture.png [/img]

Ben

On Thu, Apr 26, 2012 at 1:52 PM, Nicolas Cannasse <ncan...@motion-twin.com> wrote:
Le 26/04/2012 13:19, Benjamin Dubois a écrit :

Interesting. why not putting it in haxelib ?

a) not much time
b) better to have it there while people are playing with it

We will add it either to haxelib or haxe std library if there is an interest for it.


Best,
Nicolas

Simon Krajewski

unread,
Apr 26, 2012, 9:24:49 AM4/26/12
to haxe...@googlegroups.com
Would it make sense to add local support for
haxelib github ncannasse/markaxe src
or do you insist on keeping library stuff centralized to lib.haxe.org?
In that case, could above command line be used to actually update an
online haxelib lib from github after it was initially created?

Simon

Nicolas Cannasse

unread,
Apr 26, 2012, 9:26:54 AM4/26/12
to haxe...@googlegroups.com
Le 26/04/2012 15:08, Benjamin Dubois a �crit :
> I've seen in the tests that it is possible to create span or div using
> [my_span_class] Content of my span [/my_span_class]
> [my_div_class]\n Content of my div \n[/my_div_class]
>
> will result in the following
> <span class="my_span_class"> Content of my span </span>
> <div class="my_div_class"> Content of my div </div>

Yes.

Please note that this is default behavior only : you can customize the
way each tag is formated.

The only difference for the parser is that div's can contain other
blocks (paragraphs, lists, titles, etc.) while spans can't.

> my question is about that from the readme
> |[tag=attrib]...[/tab]| : same but with an attribute (can be anything
> not including ] or newlines)
> Does that me I can add attributes by nesting a tag inside like that :
> [my_span_class] [my_span_class=id] my_span_id [/my_span_class] Content
> of my span [/my_span_class]

No, it's more like you can do :

[my_span_class={id:myid}]....[/my_span_class]

and you will get "{id:myid}" into the "attribute" parameter for
formatTag. You can parse this attribute the way you want to extract its
id, then format it back into HTML as you wish.

> Am I right, or it is restricted to html tags and should be used like that
> [img=src] /images/my_picture.png [/img]

That's also a possibility, but then you don't need "src".

Again, you get a call with :
- the tag name "img"
- the tag attribute "src" (or null if no attribute value)
- the content (already formatted)

Then it's up to you to return anything, html or not.

Best,
Nicolas

Nicolas Cannasse

unread,
Apr 26, 2012, 9:27:38 AM4/26/12
to haxe...@googlegroups.com
Le 26/04/2012 15:24, Simon Krajewski a �crit :
Is that an actual patch proposal ? :)

Nicolas

Simon Krajewski

unread,
Apr 26, 2012, 9:32:59 AM4/26/12
to haxe...@googlegroups.com
Yes I can work on that. I just need to know what we want to support here:
a) users being able to directly install libs from github without
lib.haxe.org or
b) authors being able to update their lib.haxe.org libs from github.

Simon

Jason O'Neil

unread,
Apr 26, 2012, 9:55:31 AM4/26/12
to haxe...@googlegroups.com

Both? ;)

...

Sent from my phone, so apologies for any typos...

On Apr 26, 2012 9:33 PM, "Simon Krajewski" <simon.k...@simn.de> wrote:
Am 26.04.2012 15:27, schrieb Nicolas Cannasse:

Nicolas Cannasse

unread,
Apr 26, 2012, 10:12:31 AM4/26/12
to haxe...@googlegroups.com
Le 26/04/2012 15:32, Simon Krajewski a �crit :
I think (a) is enough right now.
Also please don't name it "github" but git :

haxelib git libname gitpath[@rev]

I guess you should also treat these as "dev" libs.

Best,
Nicolas






Jason O'Neil

unread,
Apr 26, 2012, 10:39:40 AM4/26/12
to haxe...@googlegroups.com
+1 for using standard git address, not github.

I imagine you'd need:
  • Full path to the repo: g...@github.com:jasononeil/domtools.git
  • Branch / Tag to use: "master" or "v1.0" etc
  • Path inside repo:"src/", unless you assume the repo is the correct structure for haxelib, good to go.  That works too.
Would be great to have the option to use a private repository for haxelib, for internal use at a company etc.  Excited to see this coming :)

On Thu, Apr 26, 2012 at 10:12 PM, Nicolas Cannasse <ncan...@motion-twin.com> wrote:
Le 26/04/2012 15:32, Simon Krajewski a écrit :
Am 26.04.2012 15:27, schrieb Nicolas Cannasse:
Le 26/04/2012 15:24, Simon Krajewski a écrit :
Am 26.04.2012 13:52, schrieb Nicolas Cannasse:
Le 26/04/2012 13:19, Benjamin Dubois a écrit :
Interesting. why not putting it in haxelib ?

a) not much time
b) better to have it there while people are playing with it

We will add it either to haxelib or haxe std library if there is an
interest for it.

Would it make sense to add local support for
haxelib github ncannasse/markaxe src
or do you insist on keeping library stuff centralized to lib.haxe.org?
In that case, could above command line be used to actually update an
online haxelib lib from github after it was initially created?

Is that an actual patch proposal ? :)

Yes I can work on that. I just need to know what we want to support here:
a) users being able to directly install libs from github without
lib.haxe.org or
I think (a) is enough right now.
Also please don't name it "github" but git :

haxelib git libname gitpath[@rev]

I guess you should also treat these as "dev" libs.

Best,
Nicolas

Simon Krajewski

unread,
Apr 26, 2012, 11:23:27 AM4/26/12
to haxe...@googlegroups.com
Focussing on github would have some advantages though, the most
important one being the clear user/project path which can be used for
haxelib.xml. I also like the fact that git involvement is not so
obvious, it could actually be completely hidden by convention that /
means github: haxelib install ncannasse/markaxe. But it's true that we
should go for the more general approach here, so I will support
arbitrary git paths instead.

Can we lift the alphanumeric restriction on .current's content then?
That would greatly simplify some things because we could directly point
to the src directory of a cloned ncannasse/markaxe for example.

Simon

Simon Krajewski

unread,
Apr 26, 2012, 11:32:42 AM4/26/12
to haxe...@googlegroups.com
Am 26.04.2012 17:23, schrieb Simon Krajewski:
> Can we lift the alphanumeric restriction on .current's content then?
> That would greatly simplify some things because we could directly
> point to the src directory of a cloned ncannasse/markaxe for example.

Actually I can probably use dev for that, so it should be fine.

Simon

Simon Krajewski

unread,
Apr 26, 2012, 1:30:09 PM4/26/12
to haxe...@googlegroups.com
Am 26.04.2012 16:39, schrieb Jason O'Neil:
+1 for using standard git address, not github.

I imagine you'd need:
  • Full path to the repo: g...@github.com:jasononeil/domtools.git
  • Branch / Tag to use: "master" or "v1.0" etc
  • Path inside repo:"src/", unless you assume the repo is the correct structure for haxelib, good to go.  That works too.
Would be great to have the option to use a private repository for haxelib, for internal use at a company etc.  Excited to see this coming :)

I've commited initial support to haxe SVN, please check it out.

Usage: haxelib git markaxe https://github.com/ncannasse/markaxe src

Issues:
1. haxelib.xml requires a license, which I obviously have no information of. Not sure what to do about this.
2. Likewise, I cannot determine any author. I could add that for github URLs though.
3. There is no support for haxelib remove and I don't think we actually want to support it. People might think that it just removes a git lib from the haxelib list, while it would actually erase the cloned repository along with all changes made.

Simon

Benjamin Dubois

unread,
Apr 26, 2012, 5:47:42 PM4/26/12
to haxe...@googlegroups.com
I have a strange behavior of the parser that doesn't provide me div where it should
[d]\nq\n[/d]
still gives me a
<span class="d">\nq\n<span>
instead of
<div class="d">q<div>

Ben
Reply all
Reply to author
Forward
0 new messages