@@ -50,7 +50,8 @@ import Control.Monad
5050import Data.List (intersperse, intercalate, isPrefixOf )
5151import Text.HTML.TagSoup
5252import Data.Sequence (viewl, ViewL(..), (<|))
53−import Data.Char (isDigit)
53+import qualified Data.Foldable as F
54+import Data.Char (isDigit, isSpace)
5455
5556-- | Read mediawiki from an input string and return a Pandoc document.
5657readMediaWiki :: ReaderOptions -- ^ Reader options
@@ -175,7 +176,11 @@ block = mempty <$ skipMany1 blankline
175176 <|> para
176177
177178para :: MWParser Blocks
178−para = B.para . trimInlines . mconcat <$> many1 inline
179+para = do
180+ contents <- trimInlines . mconcat <$> many1 inline
181+ if F.all (==Space) contents
182+ then return mempty
183+ else return $ B.para contents
179184
180185table :: MWParser Blocks
181186table = do
@@ -330,10 +335,16 @@ preformatted = try $ do
330335 lines . fromEntities . map spToNbsp <$> try
331336 (htmlTag (~== TagOpen "nowiki" []) *>
332337 manyTill anyChar (htmlTag (~== TagClose "nowiki")))
333− let inline' = whitespace' <|> endline' <|> nowiki' <|> inline
338+ let inline' = whitespace' <|> endline' <|> nowiki'
339+ <|> (notFollowedBy newline *> inline)
334340 let strToCode (Str s) = Code ("",[],[]) s
335341 strToCode x = x
336− B.para . bottomUp strToCode . mconcat <$> many1 inline'
342+ contents <- mconcat <$> many1 inline'
343+ let spacesStr (Str xs) = all isSpace xs
344+ spacesStr _ = False
345+ if F.all spacesStr contents
346+ then return mempty
347+ else return $ B.para $ bottomUp strToCode contents
337348
338349header :: MWParser Blocks
339350header = try $ do
@@ -504,7 +515,8 @@ whitespace = B.space <$ (skipMany1 spaceChar <|> endline <|> htmlComment)
504515
505516endline :: MWParser ()
506517endline = () <$ try (newline <*
507− notFollowedBy blankline <*
518+ notFollowedBy spaceChar <*
519+ notFollowedBy newline <*
508520 notFollowedBy' hrule <*
509521 notFollowedBy tableStart <*
510522 notFollowedBy' header <*