git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: drop leading, trailing newline in pre block.

This is consistent with how the other readers work.

commit0356ad4de6f19b3804b8a635e8ce8a5582ac2c5c authorJohn MacFarlane <jgm@berkeley.edu> dateFri 3 Dec 2010, 22:42 (16 years ago) parent36d4aa4
2 files changed+12−4
src/Text/Pandoc/Readers/Textile.hs+10−2 tests/textile-reader.native+2−2
src/Text/Pandoc/Readers/Textile.hs+10−2
@@ -120,8 +120,16 @@ block = choice blockParsers <?> "block"
120120codeBlock :: GenParser Char ParserState Block
121121codeBlock = try $ do
122122 htmlTag False "pre"
123− content <- manyTill anyChar (try $ htmlEndTag "pre" >> blockBreak)
124− return $ CodeBlock ("",[],[]) content
123+ result' <- manyTill anyChar (try $ htmlEndTag "pre" >> blockBreak)
124+ -- drop leading newline if any
125+ let result'' = case result' of
126+ '\n':xs -> xs
127+ _ -> result'
128+ -- drop trailing newline if any
129+ let result''' = case reverse result'' of
130+ '\n':_ -> init result''
131+ _ -> result''
132+ return $ CodeBlock ("",[],[]) result'''
125133
126134-- | Header of the form "hN. content" with N in 1..6
127135header :: GenParser Char ParserState Block
tests/textile-reader.native+2−2
@@ -23,9 +23,9 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
2323, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
2424, Header 1 [Str "Code",Space,Str "Blocks"]
2525, Para [Str "Code",Str ":"]
26−, 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"
26+, CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
2727, Para [Str "And",Str ":"]
28−, CodeBlock ("",[],[]) "\n this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{\n"
28+, CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
2929, Header 1 [Str "Lists"]
3030, Header 2 [Str "Unordered"]
3131, Para [Str "Asterisks",Space,Str "tight",Str ":"]