module Text.Sundown.Foreign
( Extensions (..)
, noExtensions
, allExtensions
, Callbacks
, sd_markdown_new
, sd_markdown_render
, sd_markdown_free
) where
import Foreign
import Foreign.C.String
import Foreign.C.Types
import Text.Sundown.Buffer.Foreign
import Text.Sundown.Flag
data Extensions = Extensions
{ extNoIntraEmphasis :: Bool
, extTables :: Bool
, extFencedCode :: Bool
, extAutolink :: Bool
, extStrikethrough :: Bool
, extSpaceHeaders :: Bool
, extSuperscript :: Bool
, extLaxSpacing :: Bool
}
noExtensions :: Extensions
noExtensions = Extensions False False False False False False False False
allExtensions :: Extensions
allExtensions = Extensions True True True True True True True True
instance Flag Extensions where
flagIndexes exts =
[ (1, extNoIntraEmphasis exts)
, (2, extTables exts)
, (4, extFencedCode exts)
, (8, extAutolink exts)
, (16, extStrikethrough exts)
, (64, extSpaceHeaders exts)
, (128, extSuperscript exts)
, (256, extLaxSpacing exts)
]
data Callbacks
instance Storable Callbacks where
sizeOf _ = (104)
alignment _ = alignment (undefined :: Ptr ())
peek _ = error "Callbacks.peek is not implemented"
poke _ _ = error "Callbacks.poke is not implemented"
data Markdown
instance Storable Markdown where
sizeOf _ = error "Markdown.sizeOf is not implemented"
alignment _ = alignment (undefined :: Ptr ())
peek _ = error "Markdown.peek is not implemented"
poke _ = error "Markdown.poke is not implemented"
sd_markdown_new
:: Extensions -> CSize -> Ptr Callbacks -> Ptr () -> IO (Ptr Markdown)
sd_markdown_new extensions max_nesting callbacks opaque =
sd_markdown_new' (toCUInt extensions) max_nesting callbacks opaque
foreign import ccall "markdown.h sd_markdown_new"
sd_markdown_new'
:: CUInt -> CSize -> Ptr Callbacks -> Ptr () -> IO (Ptr Markdown)
foreign import ccall "markdown.h sd_markdown_render"
sd_markdown_render
:: Ptr Buffer -> CString -> CSize -> Ptr Markdown -> IO ()
foreign import ccall "markdown.h sd_markdown_free"
sd_markdown_free :: Ptr Markdown -> IO ()