git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: improved handling of display math.

Sometimes display math is indented with more than one colon. Previously we handled these cases badly, generating definition lists and missing the math. Closes #3362.

commit06bdb8dbab1b8909e814d95afbe6b38ebff58c55 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 19 Jan 2017, 11:24 (10 years ago) parent5bd571f
1 file changed+3−2
src/Text/Pandoc/Readers/MediaWiki.hs+3−2
src/Text/Pandoc/Readers/MediaWiki.hs+3−2
@@ -423,7 +423,8 @@ defListItem = try $ do
423423 terms <- mconcat . intersperse B.linebreak <$> many defListTerm
424424 -- we allow dd with no dt, or dt with no dd
425425 defs <- if B.isNull terms
426− then notFollowedBy (try $ string ":<math>") *>
426+ then notFollowedBy
427+ (try $ skipMany1 (char ':') >> string "<math>") *>
427428 many1 (listItem ':')
428429 else many (listItem ':')
429430 return (terms, defs)
@@ -519,7 +520,7 @@ str :: MWParser Inlines
519520str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)
520521
521522math :: MWParser Inlines
522−math = (B.displayMath . trim <$> try (char ':' >> charsInTags "math"))
523+math = (B.displayMath . trim <$> try (many1 (char ':') >> charsInTags "math"))
523524 <|> (B.math . trim <$> charsInTags "math")
524525 <|> (B.displayMath . trim <$> try (dmStart *> manyTill anyChar dmEnd))
525526 <|> (B.math . trim <$> try (mStart *> manyTill (satisfy (/='\n')) mEnd))