From 75d013f73ebaf84e1bc674e317299dbbd4f90345 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 29 Jan 2024 11:10:07 -0800 Subject: LaTeX reader: generate relative widths for `\linewidth`, `\textheight`. Closes #9388. --- src/Text/Pandoc/Readers/LaTeX.hs | 6 ++++-- test/command/9388.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 4714462fb..e35912adc 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -207,11 +207,13 @@ doLHSverb = mkImage :: PandocMonad m => [(Text, Text)] -> Text -> LP m Inlines mkImage options (T.unpack -> src) = do - let replaceTextwidth (k,v) = + let replaceRelative (k,v) = case numUnit v of Just (num, "\\textwidth") -> (k, showFl (num * 100) <> "%") + Just (num, "\\linewidth") -> (k, showFl (num * 100) <> "%") + Just (num, "\\textheight") -> (k, showFl (num * 100) <> "%") _ -> (k, v) - let kvs = map replaceTextwidth + let kvs = map replaceRelative $ filter (\(k,_) -> k `elem` ["width", "height"]) options let attr = ("",[], kvs) let alt = maybe (str "image") str $ lookup "alt" options diff --git a/test/command/9388.md b/test/command/9388.md index 291e80d58..6423b40e8 100644 --- a/test/command/9388.md +++ b/test/command/9388.md @@ -12,7 +12,7 @@ Nothing [ Plain [ Str "Example" , Space , Str "figure" ] ]) [ Plain [ Image - ( "" , [] , [ ( "width" , "50%" ) , ( "height", "50%" ) ] ) + ( "" , [] , [ ( "width" , "50%" ) , ( "height" , "50%" ) ] ) [] ( "figures/placeholder" , "" ) ] -- cgit v1.2.3