aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-10-22 10:59:07 -0700
committerJohn MacFarlane <[email protected]>2023-10-22 10:59:07 -0700
commitfbf9194e345f4e0fae287b3e32562df855c2224e (patch)
treecee28e20b71d3f5fdaf840646e8789747c8dc69f /src
parentad1a745f725e3fe12d02339b0caf1af6e8b4924f (diff)
DokuWiki reader: parse `<code>` and `<file>` as block-level code.
Previously we treated them as inline code in some contexts, but that is not how DokuWiki works. Closes #9154.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/DokuWiki.hs26
1 files changed, 9 insertions, 17 deletions
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 "<del>") (try $ string "</del>")
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