diff options
| author | John MacFarlane <[email protected]> | 2023-03-08 09:07:44 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-03-08 09:24:13 -0800 |
| commit | 1643225cdda2ed706f30cb76f536baa2de135ebc (patch) | |
| tree | 7c6d5f720fc8561712e2156f0d819339e15e75d6 | |
| parent | 92b3179e494391e1f717cf0314a0f3f15add5937 (diff) | |
Ms writer: fix handling of Figure.
The Ms writer was never updated to handle the new
Figure element now produced by the markdown reader.
See #8660.
| -rw-r--r-- | src/Text/Pandoc/Writers/Ms.hs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs index 1635d13c4..ea869c284 100644 --- a/src/Text/Pandoc/Writers/Ms.hs +++ b/src/Text/Pandoc/Writers/Ms.hs @@ -162,25 +162,6 @@ blockToMs opts (Div (ident,cls,kvs) bs) = do return $ anchor $$ res blockToMs opts (Plain inlines) = splitSentences <$> inlineListToMs' opts inlines -blockToMs opts (Para [Image attr alt (src,_tit)]) - | let ext = takeExtension (T.unpack src) in (ext == ".ps" || ext == ".eps") = do - let (mbW,mbH) = (inPoints opts <$> dimension Width attr, - inPoints opts <$> dimension Height attr) - let sizeAttrs = case (mbW, mbH) of - (Just wp, Nothing) -> space <> doubleQuotes - (literal (tshow (floor wp :: Int) <> "p")) - (Just wp, Just hp) -> space <> doubleQuotes - (literal (tshow (floor wp :: Int) <> "p")) <> - space <> - doubleQuotes (literal (tshow (floor hp :: Int))) - _ -> empty - capt <- splitSentences <$> inlineListToMs' opts alt - return $ nowrap (literal ".PSPIC " <> - doubleQuotes (literal (escapeStr opts src)) <> - sizeAttrs) $$ - literal ".ce 1000" $$ - capt $$ - literal ".ce 0" blockToMs opts (Para inlines) = do firstPara <- gets stFirstPara resetFirstPara @@ -317,7 +298,32 @@ blockToMs opts (DefinitionList items) = do contents <- mapM (definitionListItemToMs opts) items setFirstPara return (vcat contents) -blockToMs opts (Figure attr _ body) = blockToMs opts $ Div attr body +blockToMs opts (Figure figattr (Caption _ caption) body) = + case body of + [Plain [ Image attr _alt (src, _tit) ]] + | let ext = takeExtension (T.unpack src) + in (ext == ".ps" || ext == ".eps") + -> do + let (mbW,mbH) = (inPoints opts <$> dimension Width attr, + inPoints opts <$> dimension Height attr) + let sizeAttrs = case (mbW, mbH) of + (Just wp, Nothing) -> space <> doubleQuotes + (literal (tshow (floor wp :: Int) <> "p")) + (Just wp, Just hp) -> space <> doubleQuotes + (literal (tshow (floor wp :: Int) <> "p")) + <> space <> + doubleQuotes + (literal (tshow (floor hp :: Int))) + _ -> empty + capt <- blockToMs opts (Div figattr caption) + let captlines = height capt + return $ nowrap (literal ".PSPIC " <> + doubleQuotes (literal (escapeStr opts src)) <> + sizeAttrs) $$ + literal (".ce " <> tshow captlines) $$ + capt $$ + literal ".sp 1" + _ -> blockToMs opts $ Div figattr body -- | Convert bullet list item (list of blocks) to ms. bulletListItemToMs :: PandocMonad m => WriterOptions -> [Block] -> MS m (Doc Text) |
