aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/MediaWiki.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-10-18 17:50:43 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2013-10-18 17:50:43 -0700
commite5feed00f7edb0d79f717ec9815c57df696a992e (patch)
tree09a95f48a013fcf710dcc5e9919d1eb72a75427f /src/Text/Pandoc/Readers/MediaWiki.hs
parent1f29f4678e0a1b1272704e5ddafa0bee45e5e426 (diff)
downloadpandoc-e5feed00f7edb0d79f717ec9815c57df696a992e.tar.gz
MediaWiki reader: Trim contents of `<math>` tags.
Otherwise we get problems when converting to markdown. Closes #1027.
Diffstat (limited to 'src/Text/Pandoc/Readers/MediaWiki.hs')
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index 8b436c89f..136701bd0 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -43,7 +43,7 @@ import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )
import Text.Pandoc.XML ( fromEntities )
import Text.Pandoc.Parsing hiding ( nested )
import Text.Pandoc.Walk ( walk )
-import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify )
+import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify, trim )
import Data.Monoid (mconcat, mempty)
import Control.Applicative ((<$>), (<*), (*>), (<$))
import Control.Monad
@@ -475,10 +475,10 @@ str :: MWParser Inlines
str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)
math :: MWParser Inlines
-math = (B.displayMath <$> try (char ':' >> charsInTags "math"))
- <|> (B.math <$> charsInTags "math")
- <|> (B.displayMath <$> try (dmStart *> manyTill anyChar dmEnd))
- <|> (B.math <$> try (mStart *> manyTill (satisfy (/='\n')) mEnd))
+math = (B.displayMath . trim <$> try (char ':' >> charsInTags "math"))
+ <|> (B.math . trim <$> charsInTags "math")
+ <|> (B.displayMath . trim <$> try (dmStart *> manyTill anyChar dmEnd))
+ <|> (B.math . trim <$> try (mStart *> manyTill (satisfy (/='\n')) mEnd))
where dmStart = string "\\["
dmEnd = try (string "\\]")
mStart = string "\\("