Textile reader: drop leading, trailing newline in pre block.

This is consistent with how the other readers work.
This commit is contained in:
John MacFarlane 2010-12-03 22:42:18 -08:00
parent 36d4aa4a09
commit 0356ad4de6
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -23,9 +23,9 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
, Header 1 [Str "Code",Space,Str "Blocks"]
, Para [Str "Code",Str ":"]
, CodeBlock ("",[],[]) "\n ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab\n"
, CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
, Para [Str "And",Str ":"]
, CodeBlock ("",[],[]) "\n this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{\n"
, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
, Header 1 [Str "Lists"]
, Header 2 [Str "Unordered"]
, Para [Str "Asterisks",Space,Str "tight",Str ":"]