git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki reader: Allow table in table cell.
commitfc31bf27f575a0ac04c155539a095eb07fc996cc authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 15 Sep 2012, 21:06 (14 years ago) parent1461693
3 files changed+36−1
src/Text/Pandoc/Readers/MediaWiki.hs+3−1 tests/mediawiki-reader.native+13 tests/mediawiki-reader.wiki+20
src/Text/Pandoc/Readers/MediaWiki.hs+3−1
@@ -30,6 +30,7 @@ Conversion of mediawiki text to 'Pandoc' document.
3030-}
3131{-
3232TODO:
33+_ correctly handle tables within tables
3334_ parse templates?
3435-}
3536module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
@@ -255,7 +256,8 @@ tableCell = try $ do
255256 attrs <- option [] $ try $ parseAttrs <$>
256257 manyTill (satisfy (/='\n')) (char '|' <* notFollowedBy (char '|'))
257258 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))
259261 bs <- parseFromString (mconcat <$> many block) ls
260262 let align = case lookup "align" attrs of
261263 Just "left" -> AlignLeft
tests/mediawiki-reader.native+13
@@ -224,5 +224,18 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
224224 ,[[Para [Str "more"]]
225225 ,[Para [Str "2.0"]]
226226 ,[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"]]]]
227240,Header 2 [Str "notes"]
228241,Para [Str "My",Space,Str "note!",Note [Plain [Str "This."]]]]
tests/mediawiki-reader.wiki+20
@@ -343,6 +343,26 @@ and cheese
343343| more || 2.0 || more
344344|}
345345
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+
346366== notes ==
347367
348368My note!<ref>This.</ref>