summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-12-16 10:19:07 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-12-16 10:19:07 -0800
commit2af6bf34f7b42947ba7f1d9b2c774147cd61f16e (patch)
treeb813f92d901a35f06028b033057c47c55cefaa8a /src
parent7c22959c95c55b4115b60e027313c1649d90d2d5 (diff)
parentf3a9bdafef45ef0990d302207410f014d75d9860 (diff)
Merge pull request #2591 from mb21/ICML-figures
ICML writer: added figure handling, closes #2590
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
index db837571e..3b0d072f6 100644
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -71,6 +71,8 @@ linkName = "Link"
-- block element names (appear in InDesign's paragraph styles pane)
paragraphName :: String
+figureName :: String
+imgCaptionName :: String
codeBlockName :: String
blockQuoteName :: String
orderedListName :: String
@@ -94,6 +96,8 @@ subListParName :: String
footnoteName :: String
citeName :: String
paragraphName = "Paragraph"
+figureName = "Figure"
+imgCaptionName = "Caption"
codeBlockName = "CodeBlock"
blockQuoteName = "Blockquote"
orderedListName = "NumList"
@@ -285,6 +289,11 @@ blocksToICML opts style lst = vcat `fmap` mapM (blockToICML opts style) lst
-- | Convert a Pandoc block element to ICML.
blockToICML :: WriterOptions -> Style -> Block -> WS Doc
blockToICML opts style (Plain lst) = parStyle opts style lst
+-- title beginning with fig: indicates that the image is a figure
+blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do
+ figure <- parStyle opts (figureName:style) img
+ caption <- parStyle opts (imgCaptionName:style) txt
+ return $ figure $$ caption
blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
blockToICML _ _ (RawBlock f str)
@@ -434,7 +443,7 @@ inlineToICML opts style (Link _ lst (url, title)) = do
cont = inTags True "HyperlinkTextSource"
[("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content
in (cont, newst)
-inlineToICML opts style (Image attr alt target) = imageICML opts style attr alt target
+inlineToICML opts style (Image attr _ target) = imageICML opts style attr target
inlineToICML opts style (Note lst) = footnoteToICML opts style lst
inlineToICML opts style (Span _ lst) = inlinesToICML opts style lst
@@ -513,8 +522,8 @@ styleToStrAttr style =
in (stlStr, attrs)
-- | Assemble an ICML Image.
-imageICML :: WriterOptions -> Style -> Attr -> [Inline] -> Target -> WS Doc
-imageICML opts style attr _ (src, _) = do
+imageICML :: WriterOptions -> Style -> Attr -> Target -> WS Doc
+imageICML opts style attr (src, _) = do
res <- liftIO $ fetchItem (writerSourceURL opts) src
imgS <- case res of
Left (_) -> do