From 7b68846b921a26e7c5688eae9a87b4f4de9b9da5 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 31 Dec 2025 10:36:02 +0100 Subject: Lua: mark readers and writers with their types. The `pandoc.readers` and `pandoc.writers` maps now have string values instead of boolean values. The string signals the type of the reader/writer, `"text"` for *TextReader*/*TextWriter* and `"bytestring"` for *ByteStringReader*/*ByteStringWriter*. Closes: #11367 --- pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pandoc-lua-engine/src') diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs index 850f9a925..7c0408d63 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs @@ -57,7 +57,6 @@ import Text.Pandoc.Writers (Writer (..), getWriter, writers) import qualified HsLua as Lua import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy.Char8 as BSL -import qualified Data.Set as Set import qualified Data.Text as T import qualified Text.Pandoc.UTF8 as UTF8 @@ -98,9 +97,13 @@ readersField = Field [ "Set of formats that pandoc can parse. All keys in this table can" , "be used as the `format` value in `pandoc.read`." ] - , fieldPushValue = pushSet pushText $ - Set.fromList (map fst (readers @PandocLua)) + , fieldPushValue = pushKeyValuePairs pushText (pushText . readerType) + (readers @PandocLua) } + where + readerType = \case + TextReader {} -> "text" + ByteStringReader {} -> "bytestring" -- | Set of input formats accepted by @write@. writersField :: Field PandocError @@ -111,9 +114,13 @@ writersField = Field [ "Set of formats that pandoc can generate. All keys in this table" , "can be used as the `format` value in `pandoc.write`." ] - , fieldPushValue = pushSet pushText $ - Set.fromList (map fst (writers @PandocLua)) + , fieldPushValue = pushKeyValuePairs pushText (pushText . writerType) + (writers @PandocLua) } + where + writerType = \case + TextWriter {} -> "text" + ByteStringWriter {} -> "bytestring" -- | Inline table field inlineField :: Field PandocError -- cgit v1.2.3