[ocaml-infra] markdown in "pure" OCaml: testing phase

Thomas Gazagnaire thomas at ocamlpro.com
Thu Aug 8 19:43:18 BST 2013


> unless I have forgotten some features, I think I have just finished implementing a whole Markdown to HTML converter, with original specs [1] in mind.

Great!

> I have done very little testing on omd, so it might still have plenty of bugs, so I'm starting a testing phase now. So, very soon I shall make a release :-)

I advise you again to look at https://github.com/samoht/ocaml-cow/tree/WIP/lib_tests/md if you are looking for some tests.

> If you want to try it out, your feedbacks will be welcome. Note that for the moment, the binary doesn't parse its arguments, so it's all about stdin and stdout.

If you want to make everybody happy, the simple 'extension point' mechanism is to add a way to add HTML tags to some word/paragraph (and a way to load css & javascript files in the generated HTML file). I've never seen any markdown engine doing this, but that would be incredibly useful (at least for me).

One idea for the syntax could be:

```
[ ... some markdown ... ]
[foo[
[ ... some markdown ... ]
]]
[ ... some markdown ... ]
```

which can be translated into:

```
[ ... some HTML ... ] 
<span class="foo">
[ ... some HTML ... ]
</span>
[ ... some HTML ...]
```

An other idea is to malformed HTML fragments when a line starts by '<':

[... some markdown ... ]
<span class="foo">
[ ... some markdown ... ]
</span>
[... some markdown ... ]
```

(which will be translated to the same HTML fragment as above)

You can even be brave and hack your parser to accept the one-line:

```
[ ... some markdown ... ] <span class="foo">[ ... some markdowm ...]</span> [ ... some markdown ... ]
```

Which will be translated to:
```
[ ... some HTML  ... ]<span class="foo">[... some HTML ...]</span> [ ... some markdown ... ]
```

Not sure which idea is best, though, it's really depends if you want to be compatible with other markdown engines.

> N.B. I'll probably add a table of contents extension, eventually.

You can be interested in https://github.com/mirage/ocaml-cow/blob/master/lib/markdown.ml#L456

--
Thomas


More information about the Infrastructure mailing list