@@ -50,7 +50,8 @@ import Control.Monad
50import Data.List (intersperse, intercalate, isPrefixOf )
50import Data.List (intersperse, intercalate, isPrefixOf )
51import Text.HTML.TagSoup
51import Text.HTML.TagSoup
52import Data.Sequence (viewl, ViewL(..), (<|))
52import Data.Sequence (viewl, ViewL(..), (<|))
53+import qualified Data.Foldable as F
53−import Data.Char (isDigit)
54+import Data.Char (isDigit, isSpace)
55-- | Read mediawiki from an input string and return a Pandoc document.
56-- | Read mediawiki from an input string and return a Pandoc document.
56readMediaWiki :: ReaderOptions -- ^ Reader options
57readMediaWiki :: ReaderOptions -- ^ Reader options
@@ -175,7 +176,11 @@ block = mempty <$ skipMany1 blankline
177para :: MWParser Blocks
178para :: MWParser Blocks
178−para = B.para . trimInlines . mconcat <$> many1 inline
180+ contents <- trimInlines . mconcat <$> many1 inline
181+ if F.all (==Space) contents
183+ else return $ B.para contents
180table :: MWParser Blocks
185table :: MWParser Blocks
181table = do
186table = do
@@ -330,10 +335,16 @@ preformatted = try $ do
330 lines . fromEntities . map spToNbsp <$> try
335 lines . fromEntities . map spToNbsp <$> try
331 (htmlTag (~== TagOpen "nowiki" []) *>
336 (htmlTag (~== TagOpen "nowiki" []) *>
332 manyTill anyChar (htmlTag (~== TagClose "nowiki")))
337 manyTill anyChar (htmlTag (~== TagClose "nowiki")))
333− let inline' = whitespace' <|> endline' <|> nowiki' <|> inline
338+ let inline' = whitespace' <|> endline' <|> nowiki'
339+ <|> (notFollowedBy newline *> inline)
334 let strToCode (Str s) = Code ("",[],[]) s
340 let strToCode (Str s) = Code ("",[],[]) s
335 strToCode x = x
341 strToCode x = x
336− B.para . bottomUp strToCode . mconcat <$> many1 inline'
342+ contents <- mconcat <$> many1 inline'
343+ let spacesStr (Str xs) = all isSpace xs
345+ if F.all spacesStr contents
347+ else return $ B.para $ bottomUp strToCode contents
338header :: MWParser Blocks
349header :: MWParser Blocks
339header = try $ do
350header = try $ do
@@ -504,7 +515,8 @@ whitespace = B.space <$ (skipMany1 spaceChar <|> endline <|> htmlComment)
505endline :: MWParser ()
516endline :: MWParser ()
506endline = () <$ try (newline <*
517endline = () <$ try (newline <*
507− notFollowedBy blankline <*
518+ notFollowedBy spaceChar <*
519+ notFollowedBy newline <*
508 notFollowedBy' hrule <*
520 notFollowedBy' hrule <*
509 notFollowedBy tableStart <*
521 notFollowedBy tableStart <*
510 notFollowedBy' header <*
522 notFollowedBy' header <*