git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: Allow table in table cell.
fc31bf2John MacFarlane
src/Text/Pandoc/Readers/MediaWiki.hs+3−1
@@ -30,6 +30,7 @@ Conversion of mediawiki text to 'Pandoc' document.
30-}
30-}
31{-
31{-
32TODO:
32TODO:
33+_ correctly handle tables within tables
33_ parse templates?
34_ parse templates?
34-}
35-}
35module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
36module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
@@ -255,7 +256,8 @@ tableCell = try $ do
255 attrs <- option [] $ try $ parseAttrs <$>
256 attrs <- option [] $ try $ parseAttrs <$>
256 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
257 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
257 skipMany spaceChar
258 skipMany spaceChar
258− ls <- many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *> anyChar)
259+ ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>
260+ ((snd <$> withRaw table) <|> count 1 anyChar))
259 bs <- parseFromString (mconcat <$> many block) ls
261 bs <- parseFromString (mconcat <$> many block) ls
260 let align = case lookup "align" attrs of
262 let align = case lookup "align" attrs of
261 Just "left" -> AlignLeft
263 Just "left" -> AlignLeft
tests/mediawiki-reader.native+13
@@ -224,5 +224,18 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
224 ,[[Para [Str "more"]]
224 ,[[Para [Str "more"]]
225 ,[Para [Str "2.0"]]
225 ,[Para [Str "2.0"]]
226 ,[Para [Str "more"]]]]
226 ,[Para [Str "more"]]]]
227+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
228+ [[]
229+ ,[]]
230+ [[[Para [Str "Orange"]]
231+ ,[Para [Str "Apple"]]]
232+ ,[[Para [Str "Bread"]]
233+ ,[Table [] [AlignDefault,AlignDefault] [0.0,0.0]
234+ [[Para [Str "fruit"]]
235+ ,[Para [Str "topping"]]]
236+ [[[Para [Str "apple"]]
237+ ,[Para [Str "ice",Space,Str "cream"]]]]]]
238+ ,[[Para [Str "Butter"]]
239+ ,[Para [Str "Ice",Space,Str "cream"]]]]
227,Header 2 [Str "notes"]
240,Header 2 [Str "notes"]
228,Para [Str "My",Space,Str "note!",Note [Plain [Str "This."]]]]
241,Para [Str "My",Space,Str "note!",Note [Plain [Str "This."]]]]
tests/mediawiki-reader.wiki+20
@@ -343,6 +343,26 @@ and cheese
343| more || 2.0 || more
343| more || 2.0 || more
344|}
344|}
345
345
346+{|
347+|-
348+|Orange
349+|Apple
350+|-
351+|Bread
352+|
353+{|
354+!fruit
355+!topping
356+|-
357+|apple
358+|ice cream
359+|}
360+|-
361+|Butter
362+|Ice cream
363+|}
364+
365+
346== notes ==
366== notes ==
347
367
348My note!<ref>This.</ref>
368My note!<ref>This.</ref>