Haskell - Parsec Parsing <p> element
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-04-28T20:19:53Z
Indexed on
2010/04/28
20:37 UTC
Read the original article
Hit count: 285
I'm using Text.ParserCombinators.Parsec and Text.XHtml to parse an input like this:
This is the first paragraph example\n with two lines\n \n And this is the second paragraph\n
And my output should be:
<p>This is the first paragraph example\n
with two lines\n</p>
<p>And this is the second paragraph\n</p>
I defined:
line= do{
;t<-manyTill (anyChar) newline
;return t
}
paragraph = do{
t<-many1 (line)
;return ( p << t )
}
But it returns:
<p>This is the first paragraph example\n
with two lines\n\n And this is the second paragraph\n</p>
What is wrong? Any ideas?
Thanks!
© Stack Overflow or respective owner