aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine/src/Text/Pandoc/Lua/Marshal/ImageSize.hs
blob: e56b5cd25a7c76c0981d8da4c44b44aec64374e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# LANGUAGE LambdaCase           #-}
{-# LANGUAGE OverloadedStrings    #-}
{- |
   Module      : Text.Pandoc.Lua.Marshal.ImageSize
   Copyright   : © 2024 Albert Krewinkel
   License     : GPL-2.0-or-later
   Maintainer  : Albert Krewinkel <[email protected]>

Marshaling image properties.
-}
module Text.Pandoc.Lua.Marshal.ImageSize
  ( pushImageType
  , pushImageSize
  ) where

import Data.Char (toLower)
import HsLua
import Text.Pandoc.ImageSize

-- | Pushes an 'ImageType' as a string value.
pushImageType :: LuaError e => Pusher e ImageType
pushImageType = pushString . map toLower . show

-- | Pushes a dimensional value.
pushImageSize :: LuaError e => Pusher e ImageSize
pushImageSize = pushAsTable
  [ ("width", pushIntegral . pxX)
  , ("height", pushIntegral . pxY)
  , ("dpi_horz", pushIntegral . dpiX)
  , ("dpi_vert", pushIntegral . dpiY)
  ]