diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2018-10-12 21:13:44 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2018-10-12 21:13:44 +0200 |
commit | 3db9e15689766b7f416e0410252297dff11bd770 (patch) | |
tree | 819aa53e610c6af907ced81da3b2498095af7e19 /src/Text/Pandoc | |
parent | 1ac87b487f16834022a6995278212205dd4bc72e (diff) | |
download | pandoc-3db9e15689766b7f416e0410252297dff11bd770.tar.gz |
Lua filters: push ListAttributes via constructor
This ensures that ListAttributes, as present in OrderedList elements,
have additional accessors (viz. *start*, *style*, and *delimiter*).
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Lua/Init.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Lua/StackInstances.hs | 18 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs index 35611d481..8449d736d 100644 --- a/src/Text/Pandoc/Lua/Init.hs +++ b/src/Text/Pandoc/Lua/Init.hs @@ -111,6 +111,7 @@ putConstructorsInRegistry = do constrsToReg $ Pandoc.MetaList mempty constrsToReg $ Pandoc.Citation mempty mempty mempty Pandoc.AuthorInText 0 0 putInReg "Attr" -- used for Attr type alias + putInReg "ListAttributes" -- used for ListAttributes type alias Lua.pop 1 where constrsToReg :: Data a => a -> Lua () diff --git a/src/Text/Pandoc/Lua/StackInstances.hs b/src/Text/Pandoc/Lua/StackInstances.hs index 931b8c225..8538a14ee 100644 --- a/src/Text/Pandoc/Lua/StackInstances.hs +++ b/src/Text/Pandoc/Lua/StackInstances.hs @@ -185,7 +185,8 @@ pushBlock = \case Header lvl attr inlns -> pushViaConstructor "Header" lvl inlns (LuaAttr attr) HorizontalRule -> pushViaConstructor "HorizontalRule" LineBlock blcks -> pushViaConstructor "LineBlock" blcks - OrderedList lstAttr list -> pushViaConstructor "OrderedList" list lstAttr + OrderedList lstAttr list -> pushViaConstructor "OrderedList" list + (LuaListAttributes lstAttr) Null -> pushViaConstructor "Null" Para blcks -> pushViaConstructor "Para" blcks Plain blcks -> pushViaConstructor "Plain" blcks @@ -207,7 +208,9 @@ peekBlock idx = defineHowTo "get Block value" $ do <$> elementContent "HorizontalRule" -> return HorizontalRule "LineBlock" -> LineBlock <$> elementContent - "OrderedList" -> uncurry OrderedList <$> elementContent + "OrderedList" -> (\(LuaListAttributes lstAttr, lst) -> + OrderedList lstAttr lst) + <$> elementContent "Null" -> return Null "Para" -> Para <$> elementContent "Plain" -> Plain <$> elementContent @@ -289,6 +292,17 @@ instance Pushable LuaAttr where instance Peekable LuaAttr where peek idx = defineHowTo "get Attr value" (LuaAttr <$> Lua.peek idx) +-- | Wrapper for ListAttributes +newtype LuaListAttributes = LuaListAttributes ListAttributes + +instance Pushable LuaListAttributes where + push (LuaListAttributes (start, style, delimiter)) = + pushViaConstructor "ListAttributes" start style delimiter + +instance Peekable LuaListAttributes where + peek = defineHowTo "get ListAttributes value" . + fmap LuaListAttributes . Lua.peek + -- -- Hierarchical elements -- |