git.iko.soy/typeable/pandoc
on master help sign in
Lua filters: push ListAttributes via constructor
3db9e15Albert Krewinkel
src/Text/Pandoc/Lua/Init.hs+1
@@ -111,6 +111,7 @@ putConstructorsInRegistry = do
111 constrsToReg $ Pandoc.MetaList mempty
111 constrsToReg $ Pandoc.MetaList mempty
112 constrsToReg $ Pandoc.Citation mempty mempty mempty Pandoc.AuthorInText 0 0
112 constrsToReg $ Pandoc.Citation mempty mempty mempty Pandoc.AuthorInText 0 0
113 putInReg "Attr" -- used for Attr type alias
113 putInReg "Attr" -- used for Attr type alias
114+ putInReg "ListAttributes" -- used for ListAttributes type alias
114 Lua.pop 1
115 Lua.pop 1
115 where
116 where
116 constrsToReg :: Data a => a -> Lua ()
117 constrsToReg :: Data a => a -> Lua ()
src/Text/Pandoc/Lua/StackInstances.hs+16−2
@@ -185,7 +185,8 @@ pushBlock = \case
185 Header lvl attr inlns -> pushViaConstructor "Header" lvl inlns (LuaAttr attr)
185 Header lvl attr inlns -> pushViaConstructor "Header" lvl inlns (LuaAttr attr)
186 HorizontalRule -> pushViaConstructor "HorizontalRule"
186 HorizontalRule -> pushViaConstructor "HorizontalRule"
187 LineBlock blcks -> pushViaConstructor "LineBlock" blcks
187 LineBlock blcks -> pushViaConstructor "LineBlock" blcks
188− OrderedList lstAttr list -> pushViaConstructor "OrderedList" list lstAttr
188+ OrderedList lstAttr list -> pushViaConstructor "OrderedList" list
189+ (LuaListAttributes lstAttr)
189 Null -> pushViaConstructor "Null"
190 Null -> pushViaConstructor "Null"
190 Para blcks -> pushViaConstructor "Para" blcks
191 Para blcks -> pushViaConstructor "Para" blcks
191 Plain blcks -> pushViaConstructor "Plain" blcks
192 Plain blcks -> pushViaConstructor "Plain" blcks
@@ -207,7 +208,9 @@ peekBlock idx = defineHowTo "get Block value" $ do
207 <$> elementContent
208 <$> elementContent
208 "HorizontalRule" -> return HorizontalRule
209 "HorizontalRule" -> return HorizontalRule
209 "LineBlock" -> LineBlock <$> elementContent
210 "LineBlock" -> LineBlock <$> elementContent
211+ "OrderedList" -> (\(LuaListAttributes lstAttr, lst) ->
212+ OrderedList lstAttr lst)
210− "OrderedList" -> uncurry OrderedList <$> elementContent
213+ <$> elementContent
211 "Null" -> return Null
214 "Null" -> return Null
212 "Para" -> Para <$> elementContent
215 "Para" -> Para <$> elementContent
213 "Plain" -> Plain <$> elementContent
216 "Plain" -> Plain <$> elementContent
@@ -289,6 +292,17 @@ instance Pushable LuaAttr where
289instance Peekable LuaAttr where
292instance Peekable LuaAttr where
290 peek idx = defineHowTo "get Attr value" (LuaAttr <$> Lua.peek idx)
293 peek idx = defineHowTo "get Attr value" (LuaAttr <$> Lua.peek idx)
291
294
295+-- | Wrapper for ListAttributes
296+newtype LuaListAttributes = LuaListAttributes ListAttributes
297+
298+instance Pushable LuaListAttributes where
299+ push (LuaListAttributes (start, style, delimiter)) =
300+ pushViaConstructor "ListAttributes" start style delimiter
301+
302+instance Peekable LuaListAttributes where
303+ peek = defineHowTo "get ListAttributes value" .
304+ fmap LuaListAttributes . Lua.peek
305+
292--
306--
293-- Hierarchical elements
307-- Hierarchical elements
294--
308--