git.iko.soy/typeable/pandoc
on master help sign in
Textile reader: support "pre." for code blocks.

Cloess #6454.

commitfa6ffcaf02033ee555f59147f4a1d30c4cb9883e authorJohn MacFarlane <jgm@berkeley.edu> dateSat 13 Jun 2020, 10:59 (6 years ago) parentde4fb05
1 file changed+8−8
src/Text/Pandoc/Readers/Textile.hs+8−8
src/Text/Pandoc/Readers/Textile.hs+8−8
@@ -133,14 +133,14 @@ commentBlock = try $ do
133133 return mempty
134134
135135codeBlock :: PandocMonad m => ParserT Text ParserState m Blocks
136−codeBlock = codeBlockBc <|> codeBlockPre
136+codeBlock = codeBlockTextile <|> codeBlockHtml
137137
138−codeBlockBc :: PandocMonad m => ParserT Text ParserState m Blocks
139−codeBlockBc = try $ do
140− string "bc."
138+codeBlockTextile :: PandocMonad m => ParserT Text ParserState m Blocks
139+codeBlockTextile = try $ do
140+ string "bc." <|> string "pre."
141141 extended <- option False (True <$ char '.')
142142 char ' '
143− let starts = ["p", "table", "bq", "bc", "h1", "h2", "h3",
143+ let starts = ["p", "table", "bq", "bc", "pre", "h1", "h2", "h3",
144144 "h4", "h5", "h6", "pre", "###", "notextile"]
145145 let ender = choice $ map explicitBlockStart starts
146146 contents <- if extended
@@ -155,8 +155,8 @@ trimTrailingNewlines :: Text -> Text
155155trimTrailingNewlines = T.dropWhileEnd (=='\n')
156156
157157-- | Code Blocks in Textile are between <pre> and </pre>
158−codeBlockPre :: PandocMonad m => ParserT Text ParserState m Blocks
159−codeBlockPre = try $ do
158+codeBlockHtml :: PandocMonad m => ParserT Text ParserState m Blocks
159+codeBlockHtml = try $ do
160160 (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True))
161161 result' <- T.pack <$> manyTill anyChar (htmlTag (tagClose (=="pre")))
162162 -- drop leading newline if any
@@ -243,7 +243,7 @@ genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT Text ParserSta
243243genericListItemAtDepth c depth = try $ do
244244 count depth (char c) >> attributes >> whitespace
245245 contents <- mconcat <$> many ((B.plain . mconcat <$> many1 inline) <|>
246− try (newline >> codeBlockPre))
246+ try (newline >> codeBlockHtml))
247247 newline
248248 sublist <- option mempty (anyListAtDepth (depth + 1))
249249 return $ contents <> sublist