From fbf9194e345f4e0fae287b3e32562df855c2224e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 22 Oct 2023 10:59:07 -0700 Subject: DokuWiki reader: parse `` and `` as block-level code. Previously we treated them as inline code in some contexts, but that is not how DokuWiki works. Closes #9154. --- src/Text/Pandoc/Readers/DokuWiki.hs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/DokuWiki.hs b/src/Text/Pandoc/Readers/DokuWiki.hs index 77213a111..26a17c3ff 100644 --- a/src/Text/Pandoc/Readers/DokuWiki.hs +++ b/src/Text/Pandoc/Readers/DokuWiki.hs @@ -105,8 +105,6 @@ inline'' = br <|> superscript <|> deleted <|> footnote - <|> inlineCode - <|> inlineFile <|> inlineRaw <|> math <|> autoLink @@ -193,12 +191,6 @@ deleted = try $ B.strikeout <$> between (string "") (try $ string "") footnote :: PandocMonad m => DWParser m B.Inlines footnote = try $ B.note . B.para <$> between (string "((") (try $ string "))") nestedInlines -inlineCode :: PandocMonad m => DWParser m B.Inlines -inlineCode = codeTag B.codeWith "code" - -inlineFile :: PandocMonad m => DWParser m B.Inlines -inlineFile = codeTag B.codeWith "file" - inlineRaw :: PandocMonad m => DWParser m B.Inlines inlineRaw = try $ do char '<' @@ -247,7 +239,7 @@ str :: PandocMonad m => DWParser m B.Inlines str = B.str <$> (many1Char alphaNum <|> characterReference) symbol :: PandocMonad m => DWParser m B.Inlines -symbol = B.str <$> countChar 1 nonspaceChar +symbol = B.str <$> (notFollowedBy' blockCode *> countChar 1 nonspaceChar) link :: PandocMonad m => DWParser m B.Inlines link = try $ do @@ -414,7 +406,6 @@ blockElements = horizontalLine <|> indentedCode <|> quote <|> blockCode - <|> blockFile <|> blockRaw <|> table @@ -448,8 +439,10 @@ parseList prefix marker = many1 ((<>) <$> item <*> fmap mconcat (many continuation)) where continuation = try $ list (" " <> prefix) - item = try $ textStr prefix *> char marker *> char ' ' *> itemContents - itemContents = B.plain . mconcat <$> many1Till inline' eol + item = try $ textStr prefix *> char marker *> char ' ' *> + (mconcat <$> many1 itemContents <* eol) + itemContents = (B.plain . mconcat <$> many1 inline') <|> + blockCode indentedCode :: PandocMonad m => DWParser m B.Blocks indentedCode = try $ B.codeBlock . T.unlines <$> many1 indentedLine @@ -533,10 +526,8 @@ tableCell = try $ (second (B.plain . B.trimInlines . mconcat)) <$> cellContent blockCode :: PandocMonad m => DWParser m B.Blocks -blockCode = codeTag B.codeBlockWith "code" - -blockFile :: PandocMonad m => DWParser m B.Blocks -blockFile = codeTag B.codeBlockWith "file" +blockCode = codeTag B.codeBlockWith "code" <|> + codeTag B.codeBlockWith "file" para :: PandocMonad m => DWParser m B.Blocks para = result . mconcat <$> many1Till inline endOfParaElement @@ -544,7 +535,8 @@ para = result . mconcat <$> many1Till inline endOfParaElement endOfParaElement = lookAhead $ endOfInput <|> endOfPara <|> newBlockElement endOfInput = try $ skipMany blankline >> skipSpaces >> eof endOfPara = try $ blankline >> skipMany1 blankline - newBlockElement = try $ blankline >> void blockElements + newBlockElement = try (blankline >> void blockElements) + <|> lookAhead (void blockCode) result content = if F.all (==Space) content then mempty else B.para $ B.trimInlines content -- cgit v1.2.3