summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-09-11 09:31:41 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-09-11 09:31:41 -0700
commit71841de0f3d02fc2c88d61ab5d29b7022090f5f1 (patch)
tree32fa72fc34daf2ba5f199c5971c7b0ac411983e3
parentd47eadaf5645a807385f62b5b265274594182967 (diff)
Mediawiki: Parse an image + caption in a para by itself as a figure.
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs4
-rw-r--r--tests/mediawiki-reader.native8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
index 0432915bc..8b436c89f 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -43,7 +43,7 @@ import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )
import Text.Pandoc.XML ( fromEntities )
import Text.Pandoc.Parsing hiding ( nested )
import Text.Pandoc.Walk ( walk )
-import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead )
+import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify )
import Data.Monoid (mconcat, mempty)
import Control.Applicative ((<$>), (<*), (*>), (<$))
import Control.Monad
@@ -539,7 +539,7 @@ image = try $ do
_ <- many (try $ char '|' *> imageOption)
caption <- (B.str fname <$ sym "]]")
<|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
- return $ B.image fname "image" caption
+ return $ B.image fname ("fig:" ++ stringify caption) caption
imageOption :: MWParser String
imageOption =
diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native
index a424be0ae..5ddbd309f 100644
--- a/tests/mediawiki-reader.native
+++ b/tests/mediawiki-reader.native
@@ -84,10 +84,10 @@ Pandoc (Meta {unMeta = fromList []})
,Para [Link [Str "#My",Space,Str "anchor"] ("#My_anchor","wikilink")]
,Para [Link [Str "and",Space,Str "text"] ("Page#with_anchor","wikilink")]
,Header 2 ("",[],[]) [Str "images"]
-,Para [Image [Str "caption"] ("example.jpg","image")]
-,Para [Image [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","image")]
-,Para [Image [Str "caption"] ("example.jpg","image")]
-,Para [Image [Str "example.jpg"] ("example.jpg","image")]
+,Para [Image [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","fig:the caption with external link")]
+,Para [Image [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image [Str "example.jpg"] ("example.jpg","fig:example.jpg")]
,Header 2 ("",[],[]) [Str "lists"]
,BulletList
[[Plain [Str "Start",Space,Str "each",Space,Str "line"]]