git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2591 from mb21/ICML-figures
2af6bf3John MacFarlane
src/Text/Pandoc/Writers/ICML.hs+12−3
@@ -71,6 +71,8 @@ linkName = "Link"
71
71
72-- block element names (appear in InDesign's paragraph styles pane)
72-- block element names (appear in InDesign's paragraph styles pane)
73paragraphName :: String
73paragraphName :: String
74+figureName :: String
75+imgCaptionName :: String
74codeBlockName :: String
76codeBlockName :: String
75blockQuoteName :: String
77blockQuoteName :: String
76orderedListName :: String
78orderedListName :: String
@@ -94,6 +96,8 @@ subListParName :: String
94footnoteName :: String
96footnoteName :: String
95citeName :: String
97citeName :: String
96paragraphName = "Paragraph"
98paragraphName = "Paragraph"
99+figureName = "Figure"
100+imgCaptionName = "Caption"
97codeBlockName = "CodeBlock"
101codeBlockName = "CodeBlock"
98blockQuoteName = "Blockquote"
102blockQuoteName = "Blockquote"
99orderedListName = "NumList"
103orderedListName = "NumList"
@@ -285,6 +289,11 @@ blocksToICML opts style lst = vcat `fmap` mapM (blockToICML opts style) lst
285-- | Convert a Pandoc block element to ICML.
289-- | Convert a Pandoc block element to ICML.
286blockToICML :: WriterOptions -> Style -> Block -> WS Doc
290blockToICML :: WriterOptions -> Style -> Block -> WS Doc
287blockToICML opts style (Plain lst) = parStyle opts style lst
291blockToICML opts style (Plain lst) = parStyle opts style lst
292+-- title beginning with fig: indicates that the image is a figure
293+blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do
294+ figure <- parStyle opts (figureName:style) img
295+ caption <- parStyle opts (imgCaptionName:style) txt
296+ return $ figure $$ caption
288blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
297blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
289blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
298blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
290blockToICML _ _ (RawBlock f str)
299blockToICML _ _ (RawBlock f str)
@@ -434,7 +443,7 @@ inlineToICML opts style (Link _ lst (url, title)) = do
434 cont = inTags True "HyperlinkTextSource"
443 cont = inTags True "HyperlinkTextSource"
435 [("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content
444 [("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content
436 in (cont, newst)
445 in (cont, newst)
437−inlineToICML opts style (Image attr alt target) = imageICML opts style attr alt target
446+inlineToICML opts style (Image attr _ target) = imageICML opts style attr target
438inlineToICML opts style (Note lst) = footnoteToICML opts style lst
447inlineToICML opts style (Note lst) = footnoteToICML opts style lst
439inlineToICML opts style (Span _ lst) = inlinesToICML opts style lst
448inlineToICML opts style (Span _ lst) = inlinesToICML opts style lst
440
449
@@ -513,8 +522,8 @@ styleToStrAttr style =
513 in (stlStr, attrs)
522 in (stlStr, attrs)
514
523
515-- | Assemble an ICML Image.
524-- | Assemble an ICML Image.
516−imageICML :: WriterOptions -> Style -> Attr -> [Inline] -> Target -> WS Doc
525+imageICML :: WriterOptions -> Style -> Attr -> Target -> WS Doc
517−imageICML opts style attr _ (src, _) = do
526+imageICML opts style attr (src, _) = do
518 res <- liftIO $ fetchItem (writerSourceURL opts) src
527 res <- liftIO $ fetchItem (writerSourceURL opts) src
519 imgS <- case res of
528 imgS <- case res of
520 Left (_) -> do
529 Left (_) -> do
tests/writer.icml+16−1
@@ -215,6 +215,11 @@
215 </TabList>
215 </TabList>
216 </Properties>
216 </Properties>
217 </ParagraphStyle>
217 </ParagraphStyle>
218+ <ParagraphStyle Self="ParagraphStyle/Caption" Name="Caption" LeftIndent="0">
219+ <Properties>
220+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
221+ </Properties>
222+ </ParagraphStyle>
218 <ParagraphStyle Self="ParagraphStyle/CodeBlock" Name="CodeBlock" LeftIndent="0">
223 <ParagraphStyle Self="ParagraphStyle/CodeBlock" Name="CodeBlock" LeftIndent="0">
219 <Properties>
224 <Properties>
220 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
225 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
@@ -257,6 +262,11 @@
257 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
262 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
258 </Properties>
263 </Properties>
259 </ParagraphStyle>
264 </ParagraphStyle>
265+ <ParagraphStyle Self="ParagraphStyle/Figure" Name="Figure" LeftIndent="0">
266+ <Properties>
267+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
268+ </Properties>
269+ </ParagraphStyle>
260 <ParagraphStyle Self="ParagraphStyle/Footnote &gt; CodeBlock" Name="Footnote &gt; CodeBlock" LeftIndent="0">
270 <ParagraphStyle Self="ParagraphStyle/Footnote &gt; CodeBlock" Name="Footnote &gt; CodeBlock" LeftIndent="0">
261 <Properties>
271 <Properties>
262 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
272 <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
@@ -2542,7 +2552,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{</Content>
2542 <Content> by Georges Melies (1902):</Content>
2552 <Content> by Georges Melies (1902):</Content>
2543 </CharacterStyleRange><Br />
2553 </CharacterStyleRange><Br />
2544</ParagraphStyleRange>
2554</ParagraphStyleRange>
2545−<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
2555+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Figure">
2546 <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
2556 <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
2547 <Rectangle Self="uec" StrokeWeight="0" ItemTransform="1.00000 0 0 1.00000 75.00000 -75.00000">
2557 <Rectangle Self="uec" StrokeWeight="0" ItemTransform="1.00000 0 0 1.00000 75.00000 -75.00000">
2548 <Properties>
2558 <Properties>
@@ -2568,6 +2578,11 @@ These should not be escaped: \$ \\ \&gt; \[ \{</Content>
2568 </Rectangle>
2578 </Rectangle>
2569 </CharacterStyleRange><Br />
2579 </CharacterStyleRange><Br />
2570</ParagraphStyleRange>
2580</ParagraphStyleRange>
2581+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Caption">
2582+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
2583+ <Content>lalune</Content>
2584+ </CharacterStyleRange><Br />
2585+</ParagraphStyleRange>
2571<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
2586<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
2572 <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
2587 <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
2573 <Content>Here is a movie </Content>
2588 <Content>Here is a movie </Content>