diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-03 22:42:18 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-03 23:10:52 -0800 |
commit | 0356ad4de6f19b3804b8a635e8ce8a5582ac2c5c (patch) | |
tree | 33fcd0b07aefc3c560212e77b005d77ae6870c91 /src/Text | |
parent | 36d4aa4a0998f35d4b7a9deab92a1f661d50dd9a (diff) | |
download | pandoc-0356ad4de6f19b3804b8a635e8ce8a5582ac2c5c.tar.gz |
Textile reader: drop leading, trailing newline in pre block.
This is consistent with how the other readers work.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 52eebd07f..3465eebbe 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -120,8 +120,16 @@ block = choice blockParsers <?> "block" codeBlock :: GenParser Char ParserState Block codeBlock = try $ do htmlTag False "pre" - content <- manyTill anyChar (try $ htmlEndTag "pre" >> blockBreak) - return $ CodeBlock ("",[],[]) content + result' <- manyTill anyChar (try $ htmlEndTag "pre" >> blockBreak) + -- drop leading newline if any + let result'' = case result' of + '\n':xs -> xs + _ -> result' + -- drop trailing newline if any + let result''' = case reverse result'' of + '\n':_ -> init result'' + _ -> result'' + return $ CodeBlock ("",[],[]) result''' -- | Header of the form "hN. content" with N in 1..6 header :: GenParser Char ParserState Block |