From 1b15913b6e42bdfd5c65d1e50a26e3fc807ef937 Mon Sep 17 00:00:00 2001
From: Albert Krewinkel <albert@zeitkraut.de>
Date: Sat, 17 Nov 2018 16:50:33 +0100
Subject: 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.
---
 src/Text/Pandoc/Lua/Module/Utils.hs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'src/Text/Pandoc/Lua')

diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs
index 030d6af95..01762aebf 100644
--- a/src/Text/Pandoc/Lua/Module/Utils.hs
+++ b/src/Text/Pandoc/Lua/Module/Utils.hs
@@ -32,10 +32,11 @@ module Text.Pandoc.Lua.Module.Utils
 
 import Prelude
 import Control.Applicative ((<|>))
+import Data.Char (toLower)
 import Data.Default (def)
 import Foreign.Lua (Peekable, Lua, NumResults)
 import Text.Pandoc.Class (runIO, setUserDataDir)
-import Text.Pandoc.Definition (Pandoc, Meta, MetaValue, Block, Inline)
+import Text.Pandoc.Definition (Pandoc, Meta, MetaValue (..), Block, Inline)
 import Text.Pandoc.Lua.StackInstances ()
 import Text.Pandoc.Lua.Util (addFunction)
 
@@ -111,7 +112,13 @@ stringify el = return $ case el of
   InlineElement i  -> Shared.stringify i
   BlockElement b   -> Shared.stringify b
   MetaElement m    -> Shared.stringify m
-  MetaValueElement m -> Shared.stringify m
+  MetaValueElement m -> stringifyMetaValue m
+
+stringifyMetaValue :: MetaValue -> String
+stringifyMetaValue mv = case mv of
+  MetaBool b   -> map toLower (show b)
+  MetaString s -> s
+  _            -> Shared.stringify mv
 
 data AstElement
   = PandocElement Pandoc
-- 
cgit v1.2.3