@@ -34,7 +34,6 @@ _ tests for lists
34_ support HTML lists
34_ support HTML lists
35_ support list style attributes and start values in ol lists, also
35_ support list style attributes and start values in ol lists, also
36 value attribute on li
36 value attribute on li
37−_ support <p> tags in lists (and out?)
38_ support :, ::, etc. for indent (treat as list continuation paras?)
37_ support :, ::, etc. for indent (treat as list continuation paras?)
39_ support preformatted text (lines starting with space)
38_ support preformatted text (lines starting with space)
40_ support preformatted text blocks
39_ support preformatted text blocks
@@ -69,10 +68,12 @@ import Text.Pandoc.XML ( fromEntities )
69import Text.Pandoc.Parsing
68import Text.Pandoc.Parsing
70import Text.Pandoc.Shared ( stripTrailingNewlines )
69import Text.Pandoc.Shared ( stripTrailingNewlines )
71import Data.Monoid (mconcat, mempty)
70import Data.Monoid (mconcat, mempty)
71+import qualified Data.Foldable as F
72import Control.Applicative ((<$>), (<*), (*>), (<$))
72import Control.Applicative ((<$>), (<*), (*>), (<$))
73import Control.Monad
73import Control.Monad
74import Data.List (intersperse)
74import Data.List (intersperse)
75import Text.HTML.TagSoup
75import Text.HTML.TagSoup
76+import Data.Sequence (viewl, ViewL(..), (<|))
77-- | Read mediawiki from an input string and return a Pandoc document.
78-- | Read mediawiki from an input string and return a Pandoc document.
78readMediaWiki :: ReaderOptions -- ^ Reader options
79readMediaWiki :: ReaderOptions -- ^ Reader options
@@ -140,11 +141,20 @@ block = header
140 <|> haskell
141 <|> haskell
141 <|> mempty <$ skipMany1 blankline
142 <|> mempty <$ skipMany1 blankline
142 <|> mempty <$ try (spaces *> htmlComment)
143 <|> mempty <$ try (spaces *> htmlComment)
145para :: MWParser Blocks
148para :: MWParser Blocks
146para = B.para . trimInlines . mconcat <$> many1 inline
149para = B.para . trimInlines . mconcat <$> many1 inline
151+-- We can just skip pTags, as contents will be treated as paragraphs
152+pTag :: MWParser Blocks
153+pTag = mempty <$ (htmlTag (\t -> t ~== TagOpen "p" [] || t ~== TagClose "p"))
155+blockHtml :: MWParser Blocks
156+blockHtml = (B.rawBlock "html" . snd <$> htmlTag isBlockTag)
148hrule :: MWParser Blocks
158hrule :: MWParser Blocks
149hrule = B.horizontalRule <$ try (string "----" *> many (char '-') *> newline)
159hrule = B.horizontalRule <$ try (string "----" *> many (char '-') *> newline)
@@ -223,7 +233,11 @@ listItem' c = try $ do
223 first <- manyTill anyChar newline
233 first <- manyTill anyChar newline
224 rest <- many (try $ char c *> lookAhead listStartChar *>
234 rest <- many (try $ char c *> lookAhead listStartChar *>
225 manyTill anyChar newline)
235 manyTill anyChar newline)
226− parseFromString (mconcat <$> many1 block) $ unlines $ first : rest
236+ contents <- parseFromString (mconcat <$> many1 block)
237+ $ unlines $ first : rest
238+ case viewl (B.unMany contents) of
239+ (Para xs) :< rest -> return $ B.Many $ (Plain xs) <| rest
240+ _ -> return contents
229-- inline parsers
243-- inline parsers