diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-06-13 10:59:02 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-06-13 10:59:02 -0700 |
commit | fa6ffcaf02033ee555f59147f4a1d30c4cb9883e (patch) | |
tree | 62120a64d3d3a93ec114f6877a537a012226caa7 | |
parent | de4fb05dcc597171a5cbaac44664110c5fc0b44c (diff) | |
download | pandoc-fa6ffcaf02033ee555f59147f4a1d30c4cb9883e.tar.gz |
Textile reader: support "pre." for code blocks.
Cloess #6454.
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 598420a0d..b105b587d 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -133,14 +133,14 @@ commentBlock = try $ do return mempty codeBlock :: PandocMonad m => ParserT Text ParserState m Blocks -codeBlock = codeBlockBc <|> codeBlockPre +codeBlock = codeBlockTextile <|> codeBlockHtml -codeBlockBc :: PandocMonad m => ParserT Text ParserState m Blocks -codeBlockBc = try $ do - string "bc." +codeBlockTextile :: PandocMonad m => ParserT Text ParserState m Blocks +codeBlockTextile = try $ do + string "bc." <|> string "pre." extended <- option False (True <$ char '.') char ' ' - let starts = ["p", "table", "bq", "bc", "h1", "h2", "h3", + let starts = ["p", "table", "bq", "bc", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "###", "notextile"] let ender = choice $ map explicitBlockStart starts contents <- if extended @@ -155,8 +155,8 @@ trimTrailingNewlines :: Text -> Text trimTrailingNewlines = T.dropWhileEnd (=='\n') -- | Code Blocks in Textile are between <pre> and </pre> -codeBlockPre :: PandocMonad m => ParserT Text ParserState m Blocks -codeBlockPre = try $ do +codeBlockHtml :: PandocMonad m => ParserT Text ParserState m Blocks +codeBlockHtml = try $ do (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True)) result' <- T.pack <$> manyTill anyChar (htmlTag (tagClose (=="pre"))) -- drop leading newline if any @@ -243,7 +243,7 @@ genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT Text ParserSta genericListItemAtDepth c depth = try $ do count depth (char c) >> attributes >> whitespace contents <- mconcat <$> many ((B.plain . mconcat <$> many1 inline) <|> - try (newline >> codeBlockPre)) + try (newline >> codeBlockHtml)) newline sublist <- option mempty (anyListAtDepth (depth + 1)) return $ contents <> sublist |