diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-01-29 11:10:07 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-01-29 11:11:45 -0800 |
| commit | 75d013f73ebaf84e1bc674e317299dbbd4f90345 (patch) | |
| tree | bd6fe5ac8fa9101f734f172fec564a1d6bf503b7 | |
| parent | 8b539dbf1d0699e4724da11183b4bd8a2144e81d (diff) | |
LaTeX reader: generate relative widths for `\linewidth`, `\textheight`.
Closes #9388.
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 6 | ||||
| -rw-r--r-- | 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" , "" ) ] |
