Add Millimeter constructor to Dimension in ImageSize.
Minor API change. Now sizes given in 'mm' are no longer converted to 'cm'. Closes #4012.
This commit is contained in:
parent
5f9f458df3
commit
0e57b8b85d
2 changed files with 14 additions and 1 deletions
|
@ -79,6 +79,7 @@ instance Show Direction where
|
||||||
|
|
||||||
data Dimension = Pixel Integer
|
data Dimension = Pixel Integer
|
||||||
| Centimeter Double
|
| Centimeter Double
|
||||||
|
| Millimeter Double
|
||||||
| Inch Double
|
| Inch Double
|
||||||
| Percent Double
|
| Percent Double
|
||||||
| Em Double
|
| Em Double
|
||||||
|
@ -86,6 +87,7 @@ data Dimension = Pixel Integer
|
||||||
instance Show Dimension where
|
instance Show Dimension where
|
||||||
show (Pixel a) = show a ++ "px"
|
show (Pixel a) = show a ++ "px"
|
||||||
show (Centimeter a) = showFl a ++ "cm"
|
show (Centimeter a) = showFl a ++ "cm"
|
||||||
|
show (Millimeter a) = showFl a ++ "mm"
|
||||||
show (Inch a) = showFl a ++ "in"
|
show (Inch a) = showFl a ++ "in"
|
||||||
show (Percent a) = show a ++ "%"
|
show (Percent a) = show a ++ "%"
|
||||||
show (Em a) = showFl a ++ "em"
|
show (Em a) = showFl a ++ "em"
|
||||||
|
@ -184,6 +186,7 @@ inInch opts dim =
|
||||||
case dim of
|
case dim of
|
||||||
(Pixel a) -> fromIntegral a / fromIntegral (writerDpi opts)
|
(Pixel a) -> fromIntegral a / fromIntegral (writerDpi opts)
|
||||||
(Centimeter a) -> a * 0.3937007874
|
(Centimeter a) -> a * 0.3937007874
|
||||||
|
(Millimeter a) -> a * 0.03937007874
|
||||||
(Inch a) -> a
|
(Inch a) -> a
|
||||||
(Percent _) -> 0
|
(Percent _) -> 0
|
||||||
(Em a) -> a * (11/64)
|
(Em a) -> a * (11/64)
|
||||||
|
@ -193,6 +196,7 @@ inPixel opts dim =
|
||||||
case dim of
|
case dim of
|
||||||
(Pixel a) -> a
|
(Pixel a) -> a
|
||||||
(Centimeter a) -> floor $ dpi * a * 0.3937007874 :: Integer
|
(Centimeter a) -> floor $ dpi * a * 0.3937007874 :: Integer
|
||||||
|
(Millimeter a) -> floor $ dpi * a * 0.03937007874 :: Integer
|
||||||
(Inch a) -> floor $ dpi * a :: Integer
|
(Inch a) -> floor $ dpi * a :: Integer
|
||||||
(Percent _) -> 0
|
(Percent _) -> 0
|
||||||
(Em a) -> floor $ dpi * a * (11/64) :: Integer
|
(Em a) -> floor $ dpi * a * (11/64) :: Integer
|
||||||
|
@ -225,6 +229,7 @@ scaleDimension factor dim =
|
||||||
case dim of
|
case dim of
|
||||||
Pixel x -> Pixel (round $ factor * fromIntegral x)
|
Pixel x -> Pixel (round $ factor * fromIntegral x)
|
||||||
Centimeter x -> Centimeter (factor * x)
|
Centimeter x -> Centimeter (factor * x)
|
||||||
|
Millimeter x -> Millimeter (factor * x)
|
||||||
Inch x -> Inch (factor * x)
|
Inch x -> Inch (factor * x)
|
||||||
Percent x -> Percent (factor * x)
|
Percent x -> Percent (factor * x)
|
||||||
Em x -> Em (factor * x)
|
Em x -> Em (factor * x)
|
||||||
|
@ -243,7 +248,7 @@ lengthToDim :: String -> Maybe Dimension
|
||||||
lengthToDim s = numUnit s >>= uncurry toDim
|
lengthToDim s = numUnit s >>= uncurry toDim
|
||||||
where
|
where
|
||||||
toDim a "cm" = Just $ Centimeter a
|
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 "in" = Just $ Inch a
|
||||||
toDim a "inch" = Just $ Inch a
|
toDim a "inch" = Just $ Inch a
|
||||||
toDim a "%" = Just $ Percent a
|
toDim a "%" = Just $ Percent a
|
||||||
|
|
8
test/command/4012.md
Normal file
8
test/command/4012.md
Normal file
|
@ -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>
|
||||||
|
```
|
Loading…
Reference in a new issue