@@ -65,10 +65,12 @@ import Data.List ( stripPrefix, intersperse, intercalate, sort )
6565import Data.Maybe (fromMaybe)
6666import Text.Pandoc.Pretty
6767import Text.Pandoc.Class (PandocMonad, report)
68+import Text.Pandoc.ImageSize
6869import Text.Pandoc.Logging
6970import Control.Monad.State
7071import Data.Char ( isLower, isUpper, toUpper )
7172import Text.TeXMath (writeEqn)
73+import System.FilePath (takeExtension)
7274
7375data WriterState = WriterState { stHasInlineMath :: Bool
7476 , stFirstPara :: Bool
@@ -218,6 +220,25 @@ blockToMs opts (Div _ bs) = do
218220 return res
219221blockToMs opts (Plain inlines) =
220222 liftM vcat $ mapM (inlineListToMs' opts) $ splitSentences inlines
223+blockToMs opts (Para [Image attr alt (src,_tit)])
224+ | let ext = takeExtension src in (ext == ".ps" || ext == ".eps") = do
225+ let (mbW,mbH) = (inPoints opts <$> dimension Width attr,
226+ inPoints opts <$> dimension Height attr)
227+ let sizeAttrs = case (mbW, mbH) of
228+ (Just wp, Nothing) -> space <> doubleQuotes
229+ (text (show (floor wp :: Int) ++ "p"))
230+ (Just wp, Just hp) -> space <> doubleQuotes
231+ (text (show (floor wp :: Int) ++ "p")) <>
232+ space <>
233+ doubleQuotes (text (show (floor hp :: Int)))
234+ _ -> empty
235+ capt <- inlineListToMs' opts alt
236+ return $ nowrap (text ".PSPIC -C " <>
237+ doubleQuotes (text (escapeString src)) <>
238+ sizeAttrs) $$
239+ text ".ce 1000" $$
240+ capt $$
241+ text ".ce 0"
221242blockToMs opts (Para inlines) = do
222243 firstPara <- gets stFirstPara
223244 resetFirstPara
@@ -465,11 +486,8 @@ inlineToMs opts (Link _ txt (src, _)) = do
465486 let linknote = [Plain [Str src]]
466487 inlineListToMs opts (txt ++ [Note linknote])
467488inlineToMs opts (Image attr alternate (source, tit)) = do
468− let txt = if (null alternate) || (alternate == [Str ""]) ||
469− (alternate == [Str source]) -- to prevent autolinks
470− then [Str "image"]
471− else alternate
472− linkPart <- inlineToMs opts (Link attr txt (source, tit))
489+ let alt = if null alternate then [Str "image"] else alternate
490+ linkPart <- inlineToMs opts (Link attr alt (source, tit))
473491 return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'
474492inlineToMs _ (Note contents) = do
475493 modify $ \st -> st{ stNotes = contents : stNotes st }