Parsec Haskell Lists
- by Martin
I'm using Text.ParserCombinators.Parsec and Text.XHtml to parse an input and get a HTML output.
If my input is:
* First item, First level
** First item, Second level
** Second item, Second level
* Second item, First level
My output should be:
<ul><li>First item, First level <ul><li>First item, Second level </li><li>Second item, Second level </li></ul></li><li>Second item, First level</li></ul>
I wrote this, but obviously does not work recursively
list= do{ s <- many1 item;return (olist << s) }
item= do{
(count 1 (char '*'))
;s <- manyTill anyChar newline
;return ( li << s)
}
Any ideas?
the recursion can be more than two levels
Thanks!