git.iko.soy/typeable/pandoc
on master help sign in
Lua Utils module: improve stringify

Meta value strings (MetaString) and booleans (MetaBool) are now converted to the literal string and the lowercase boolean name, respectively. Previously, all values of these types were converted to the empty string.

commit1b15913b6e42bdfd5c65d1e50a26e3fc807ef937 authorAlbert Krewinkel <albert@zeitkraut.de> dateSat 17 Nov 2018, 16:50 (8 years ago) parentf07ae68
1 file changed+9−2
src/Text/Pandoc/Lua/Module/Utils.hs+9−2
src/Text/Pandoc/Lua/Module/Utils.hs+9−2
@@ -32,10 +32,11 @@ module Text.Pandoc.Lua.Module.Utils
3232
3333import Prelude
3434import Control.Applicative ((<|>))
35+import Data.Char (toLower)
3536import Data.Default (def)
3637import Foreign.Lua (Peekable, Lua, NumResults)
3738import Text.Pandoc.Class (runIO, setUserDataDir)
38−import Text.Pandoc.Definition (Pandoc, Meta, MetaValue, Block, Inline)
39+import Text.Pandoc.Definition (Pandoc, Meta, MetaValue (..), Block, Inline)
3940import Text.Pandoc.Lua.StackInstances ()
4041import Text.Pandoc.Lua.Util (addFunction)
4142
@@ -111,7 +112,13 @@ stringify el = return $ case el of
111112 InlineElement i -> Shared.stringify i
112113 BlockElement b -> Shared.stringify b
113114 MetaElement m -> Shared.stringify m
114− MetaValueElement m -> Shared.stringify m
115+ MetaValueElement m -> stringifyMetaValue m
116+
117+stringifyMetaValue :: MetaValue -> String
118+stringifyMetaValue mv = case mv of
119+ MetaBool b -> map toLower (show b)
120+ MetaString s -> s
121+ _ -> Shared.stringify mv
115122
116123data AstElement
117124 = PandocElement Pandoc