git.iko.soy/typeable/pandoc
on master help sign in
Fix regression of DefinitionLists in custom writer
2953983Albert Krewinkel
src/Text/Pandoc/Writers/Custom.hs+11−1
@@ -87,6 +87,15 @@ instance ToLuaStack (Stringify Citation) where
87 addValue "citationNoteNum" $ citationNoteNum cit
87 addValue "citationNoteNum" $ citationNoteNum cit
88 addValue "citationHash" $ citationHash cit
88 addValue "citationHash" $ citationHash cit
89
89
90+-- | Key-value pair, pushed as a table with @a@ as the only key and @v@ as the
91+-- associated value.
92+newtype KeyValue a b = KeyValue (a, b)
93+
94+instance (ToLuaStack a, ToLuaStack b) => ToLuaStack (KeyValue a b) where
95+ push (KeyValue (k, v)) = do
96+ newtable
97+ addValue k v
98+
90data PandocLuaException = PandocLuaException String
99data PandocLuaException = PandocLuaException String
91 deriving (Show, Typeable)
100 deriving (Show, Typeable)
92
101
@@ -165,7 +174,8 @@ blockToCustom (OrderedList (num,sty,delim) items) =
165 callFunc "OrderedList" (map Stringify items) num (show sty) (show delim)
174 callFunc "OrderedList" (map Stringify items) num (show sty) (show delim)
166
175
167blockToCustom (DefinitionList items) =
176blockToCustom (DefinitionList items) =
168− callFunc "DefinitionList" (map (Stringify *** map Stringify) items)
177+ callFunc "DefinitionList"
178+ (map (KeyValue . (Stringify *** map Stringify)) items)
169
179
170blockToCustom (Div attr items) =
180blockToCustom (Div attr items) =
171 callFunc "Div" (Stringify items) (attrToMap attr)
181 callFunc "Div" (Stringify items) (attrToMap attr)