git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: drop leading, trailing newline in pre block.
0356ad4John MacFarlane
src/Text/Pandoc/Readers/Textile.hs+10−2
@@ -120,8 +120,16 @@ block = choice blockParsers <?> "block"
120codeBlock :: GenParser Char ParserState Block
120codeBlock :: GenParser Char ParserState Block
121codeBlock = try $ do
121codeBlock = try $ do
122 htmlTag False "pre"
122 htmlTag False "pre"
123− content <- manyTill anyChar (try $ htmlEndTag "pre" >> blockBreak)
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''
124− return $ CodeBlock ("",[],[]) content
132+ return $ CodeBlock ("",[],[]) result'''
125
133
126-- | Header of the form "hN. content" with N in 1..6
134-- | Header of the form "hN. content" with N in 1..6
127header :: GenParser Char ParserState Block
135header :: GenParser Char ParserState Block
tests/textile-reader.native+2−2
@@ -23,9 +23,9 @@ Pandoc (Meta {docTitle = [Str ""], docAuthors = [[Str ""]], docDate = [Str ""]})
23, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
23, Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
24, Header 1 [Str "Code",Space,Str "Blocks"]
24, Header 1 [Str "Code",Space,Str "Blocks"]
25, Para [Str "Code",Str ":"]
25, 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"
27, Para [Str "And",Str ":"]
27, 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: \\$ \\\\ \\> \\[ \\{"
29, Header 1 [Str "Lists"]
29, Header 1 [Str "Lists"]
30, Header 2 [Str "Unordered"]
30, Header 2 [Str "Unordered"]
31, Para [Str "Asterisks",Space,Str "tight",Str ":"]
31, Para [Str "Asterisks",Space,Str "tight",Str ":"]