diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2018-11-17 16:50:33 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2018-11-17 17:40:16 +0100 |
commit | 1b15913b6e42bdfd5c65d1e50a26e3fc807ef937 (patch) | |
tree | 69e4e5396720a459c5072e56c95ab163fbe3e23e /src/Text/Pandoc/Lua | |
parent | f07ae68558aafe717130817473eb2c47fb3ab9de (diff) | |
download | pandoc-1b15913b6e42bdfd5c65d1e50a26e3fc807ef937.tar.gz |
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.
Diffstat (limited to 'src/Text/Pandoc/Lua')
-rw-r--r-- | src/Text/Pandoc/Lua/Module/Utils.hs | 11 |
1 files changed, 9 insertions, 2 deletions
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 |