summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-10-31 11:58:43 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-10-31 11:58:43 -0700
commit0e57b8b85dd22b78e2f60226700260b4eb8d36ea (patch)
tree69315a9a45cc231bebe71ecadf85b9db34c7a799
parent5f9f458df394686405b525757d1b5ef3b4cbad17 (diff)
Add Millimeter constructor to Dimension in ImageSize.
Minor API change. Now sizes given in 'mm' are no longer converted to 'cm'. Closes #4012.
-rw-r--r--src/Text/Pandoc/ImageSize.hs7
-rw-r--r--test/command/4012.md8
2 files changed, 14 insertions, 1 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 27d5c6a9c..5f491e08b 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -79,6 +79,7 @@ instance Show Direction where
data Dimension = Pixel Integer
| Centimeter Double
+ | Millimeter Double
| Inch Double
| Percent Double
| Em Double
@@ -86,6 +87,7 @@ data Dimension = Pixel Integer
instance Show Dimension where
show (Pixel a) = show a ++ "px"
show (Centimeter a) = showFl a ++ "cm"
+ show (Millimeter a) = showFl a ++ "mm"
show (Inch a) = showFl a ++ "in"
show (Percent a) = show a ++ "%"
show (Em a) = showFl a ++ "em"
@@ -184,6 +186,7 @@ inInch opts dim =
case dim of
(Pixel a) -> fromIntegral a / fromIntegral (writerDpi opts)
(Centimeter a) -> a * 0.3937007874
+ (Millimeter a) -> a * 0.03937007874
(Inch a) -> a
(Percent _) -> 0
(Em a) -> a * (11/64)
@@ -193,6 +196,7 @@ inPixel opts dim =
case dim of
(Pixel a) -> a
(Centimeter a) -> floor $ dpi * a * 0.3937007874 :: Integer
+ (Millimeter a) -> floor $ dpi * a * 0.03937007874 :: Integer
(Inch a) -> floor $ dpi * a :: Integer
(Percent _) -> 0
(Em a) -> floor $ dpi * a * (11/64) :: Integer
@@ -225,6 +229,7 @@ scaleDimension factor dim =
case dim of
Pixel x -> Pixel (round $ factor * fromIntegral x)
Centimeter x -> Centimeter (factor * x)
+ Millimeter x -> Millimeter (factor * x)
Inch x -> Inch (factor * x)
Percent x -> Percent (factor * x)
Em x -> Em (factor * x)
@@ -243,7 +248,7 @@ lengthToDim :: String -> Maybe Dimension
lengthToDim s = numUnit s >>= uncurry toDim
where
toDim a "cm" = Just $ Centimeter a
- toDim a "mm" = Just $ Centimeter (a / 10)
+ toDim a "mm" = Just $ Millimeter a
toDim a "in" = Just $ Inch a
toDim a "inch" = Just $ Inch a
toDim a "%" = Just $ Percent a
diff --git a/test/command/4012.md b/test/command/4012.md
new file mode 100644
index 000000000..579ee2459
--- /dev/null
+++ b/test/command/4012.md
@@ -0,0 +1,8 @@
+```
+pandoc -f markdown-implicit_figures
+![image]
+
+[image]: http://example.com/image.jpg {height=35mm}
+^D
+<p><img src="http://example.com/image.jpg" alt="image" style="height:35mm" /></p>
+```