Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ghc-pandoc-lua-engine for 
openSUSE:Factory checked in at 2025-05-22 16:57:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-pandoc-lua-engine (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-pandoc-lua-engine.new.2732 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-pandoc-lua-engine"

Thu May 22 16:57:12 2025 rev:14 rq:1279247 version:0.4.2

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/ghc-pandoc-lua-engine/ghc-pandoc-lua-engine.changes  
    2025-03-25 22:21:15.568610813 +0100
+++ 
/work/SRC/openSUSE:Factory/.ghc-pandoc-lua-engine.new.2732/ghc-pandoc-lua-engine.changes
    2025-05-22 16:57:50.748399256 +0200
@@ -1,0 +2,6 @@
+Thu May 15 04:26:39 UTC 2025 - Peter Simons <psim...@suse.com>
+
+- Update pandoc-lua-engine to version 0.4.2.
+  Upstream does not provide a change log file.
+
+-------------------------------------------------------------------

Old:
----
  pandoc-lua-engine-0.4.1.1.tar.gz

New:
----
  pandoc-lua-engine-0.4.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-pandoc-lua-engine.spec ++++++
--- /var/tmp/diff_new_pack.FSUQ64/_old  2025-05-22 16:57:51.112414597 +0200
+++ /var/tmp/diff_new_pack.FSUQ64/_new  2025-05-22 16:57:51.116414765 +0200
@@ -20,7 +20,7 @@
 %global pkgver %{pkg_name}-%{version}
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.4.1.1
+Version:        0.4.2
 Release:        0
 Summary:        Lua engine to power custom pandoc conversions
 License:        GPL-2.0-or-later

++++++ pandoc-lua-engine-0.4.1.1.tar.gz -> pandoc-lua-engine-0.4.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pandoc-lua-engine-0.4.1.1/pandoc-lua-engine.cabal 
new/pandoc-lua-engine-0.4.2/pandoc-lua-engine.cabal
--- old/pandoc-lua-engine-0.4.1.1/pandoc-lua-engine.cabal       2001-09-09 
03:46:40.000000000 +0200
+++ new/pandoc-lua-engine-0.4.2/pandoc-lua-engine.cabal 2001-09-09 
03:46:40.000000000 +0200
@@ -1,6 +1,6 @@
 cabal-version:       2.4
 name:                pandoc-lua-engine
-version:             0.4.1.1
+version:             0.4.2
 build-type:          Simple
 license:             GPL-2.0-or-later
 license-file:        COPYING.md
@@ -26,8 +26,10 @@
                    , test/extensions.lua
                    , test/lua/*.lua
                    , test/lua/module/*.lua
+                   , test/lua/module/include.tex
                    , test/lua/module/partial.test
                    , test/lua/module/sample.svg
+                   , test/lua/module/sample.epub
                    , test/lua/module/tiny.epub
                    , test/sample.lua
                    , test/tables.custom
@@ -108,7 +110,7 @@
   build-depends:       aeson
                      , bytestring            >= 0.9     && < 0.13
                      , crypton               >= 0.30    && < 1.1
-                     , citeproc              >= 0.8     && < 0.9
+                     , citeproc              >= 0.8     && < 0.10
                      , containers            >= 0.6.0.1 && < 0.9
                      , data-default          >= 0.4     && < 0.9
                      , doclayout             >= 0.5     && < 0.6
@@ -124,7 +126,7 @@
                      , hslua-repl            >= 0.1.1   && < 0.2
                      , lpeg                  >= 1.1     && < 1.2
                      , mtl                   >= 2.2     && < 2.4
-                     , pandoc                >= 3.6     && < 3.7
+                     , pandoc                >= 3.7     && < 3.8
                      , pandoc-lua-marshal    >= 0.3     && < 0.4
                      , pandoc-types          >= 1.22    && < 1.24
                      , parsec                >= 3.1     && < 3.2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pandoc-lua-engine-0.4.1.1/src/Text/Pandoc/Lua/Module/Pandoc.hs 
new/pandoc-lua-engine-0.4.2/src/Text/Pandoc/Lua/Module/Pandoc.hs
--- old/pandoc-lua-engine-0.4.1.1/src/Text/Pandoc/Lua/Module/Pandoc.hs  
2001-09-09 03:46:40.000000000 +0200
+++ new/pandoc-lua-engine-0.4.2/src/Text/Pandoc/Lua/Module/Pandoc.hs    
2001-09-09 03:46:40.000000000 +0200
@@ -17,8 +17,9 @@
 
 import Prelude hiding (read)
 import Control.Applicative ((<|>))
-import Control.Monad (forM_, when)
+import Control.Monad (foldM, forM_, when)
 import Control.Monad.Catch (catch, handle, throwM)
+import Control.Monad.Except (MonadError (throwError))
 import Data.Data (Data, dataTypeConstrs, dataTypeOf, showConstr)
 import Data.Default (Default (..))
 import Data.Maybe (fromMaybe)
@@ -26,9 +27,13 @@
 import Data.Text.Encoding.Error (UnicodeException)
 import HsLua
 import System.Exit (ExitCode (..))
+import Text.Pandoc.Class ( PandocMonad, FileInfo (..), FileTree
+                         , addToFileTree, getCurrentTime
+                         , insertInFileTree, sandboxWithFileTree
+                         )
 import Text.Pandoc.Definition
 import Text.Pandoc.Error (PandocError (..))
-import Text.Pandoc.Format (parseFlavoredFormat)
+import Text.Pandoc.Format (FlavoredFormat, parseFlavoredFormat)
 import Text.Pandoc.Lua.Orphans ()
 import Text.Pandoc.Lua.Marshal.AST
 import Text.Pandoc.Lua.Marshal.Format (peekFlavoredFormat)
@@ -234,22 +239,28 @@
     =?> "output string, or error triple"
 
   , defun "read"
-    ### (\content mformatspec mreaderOptions ->
-          handle (failLua . show @UnicodeException) . unPandocLua $ do
-            flvrd <- maybe (parseFlavoredFormat "markdown") pure mformatspec
+    ### (\content mformatspec mreaderOptions mreadEnv -> do
             let readerOpts = fromMaybe def mreaderOptions
-            getReader flvrd >>= \case
-              (TextReader r, es)       ->
-                 r readerOpts{readerExtensions = es}
-                   (case content of
+
+                readAction :: PandocMonad m => FlavoredFormat -> m Pandoc
+                readAction flvrd = getReader flvrd >>= \case
+                  (TextReader r, es)       ->
+                    r readerOpts{readerExtensions = es} $
+                    case content of
                       Left bs       -> toSources $ UTF8.toText bs
-                      Right sources -> sources)
-              (ByteStringReader r, es) ->
-                 case content of
-                   Left bs -> r readerOpts{readerExtensions = es}
-                                (BSL.fromStrict bs)
-                   Right _ -> throwM $ PandocLuaError
-                              "Cannot use bytestring reader with Sources")
+                      Right sources -> sources
+                  (ByteStringReader r, es) ->
+                    case content of
+                      Left bs -> r readerOpts{readerExtensions = es}
+                                 (BSL.fromStrict bs)
+                      Right _ -> throwError $ PandocLuaError
+                                 "Cannot use bytestring reader with Sources"
+
+            handle (failLua . show @UnicodeException) . unPandocLua $ do
+              flvrd <- maybe (parseFlavoredFormat "markdown") pure mformatspec
+              case mreadEnv of
+                Nothing   -> readAction flvrd
+                Just tree -> sandboxWithFileTree tree (readAction flvrd))
     <#> parameter (\idx -> (Left  <$> peekByteString idx)
                        <|> (Right <$> peekSources idx))
           "string|Sources" "content" "text to parse"
@@ -257,6 +268,15 @@
                        "formatspec" "format and extensions")
     <#> opt (parameter peekReaderOptions "ReaderOptions" "reader_options"
              "reader options")
+    <#> opt (parameter peekReadEnv "table" "read_env" $ T.unlines
+            [ "If the value is not given or `nil`, then the global environment"
+            , "is used. Passing a list of filenames causes the reader to"
+            , "be run in a sandbox. The given files are read from the file"
+            , "system and provided to the sandbox via an ersatz file system."
+            , "The table can also contain mappings from filenames to"
+            , "contents, which will be used to populate the ersatz file"
+            , "system."
+            ])
     =#> functionResult pushPandoc "Pandoc" "result document"
 
   , sha1
@@ -387,3 +407,24 @@
           , if output == mempty then BSL.pack "<no output>" else output
           ]
         return (NumResults 1)
+
+-- | Peek the environment in which the `read` function operates.
+peekReadEnv :: Peeker PandocError FileTree
+peekReadEnv idx = do
+  mtime <- liftLua . unPandocLua $ getCurrentTime
+
+  -- Add files from file system
+  files <- peekList peekString idx
+  tree1 <- liftLua $
+           foldM (\tree fp -> liftIO $ addToFileTree tree fp) mempty files
+
+  -- Add files from key-value pairs
+  let toFileInfo contents = FileInfo
+        { infoFileMTime = mtime
+        , infoFileContents = contents
+        }
+  pairs <- peekKeyValuePairs peekString (fmap toFileInfo . peekByteString) idx
+  let tree2 = foldr (uncurry insertInFileTree) tree1 pairs
+
+  -- Return ersatz file system.
+  pure tree2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pandoc-lua-engine-0.4.1.1/test/lua/module/include.tex 
new/pandoc-lua-engine-0.4.2/test/lua/module/include.tex
--- old/pandoc-lua-engine-0.4.1.1/test/lua/module/include.tex   1970-01-01 
01:00:00.000000000 +0100
+++ new/pandoc-lua-engine-0.4.2/test/lua/module/include.tex     2001-09-09 
03:46:40.000000000 +0200
@@ -0,0 +1 @@
+included
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pandoc-lua-engine-0.4.1.1/test/lua/module/pandoc.lua 
new/pandoc-lua-engine-0.4.2/test/lua/module/pandoc.lua
--- old/pandoc-lua-engine-0.4.1.1/test/lua/module/pandoc.lua    2001-09-09 
03:46:40.000000000 +0200
+++ new/pandoc-lua-engine-0.4.2/test/lua/module/pandoc.lua      2001-09-09 
03:46:40.000000000 +0200
@@ -293,6 +293,62 @@
         'Unknown input format nosuchreader'
       )
     end),
+    group 'read_env' {
+      test('images are added to the mediabag', function ()
+        local epub = io.open('lua/module/sample.epub', 'rb'):read('a')
+        local _ = pandoc.read(epub, 'epub')
+        assert.are_equal(#pandoc.mediabag.list(), 1)
+      end),
+      test('images from EPUB are added when using the sandbox', function ()
+        local epub = io.open('lua/module/sample.epub', 'rb'):read('a')
+        local _ = pandoc.read(epub, 'epub', nil, {})
+        assert.are_equal(#pandoc.mediabag.list(), 1)
+      end),
+      test('includes work in global env', function ()
+        local tex = '\\include{lua/module/include.tex}'
+        local doc = pandoc.read(tex, 'latex')
+        assert.are_equal(
+          doc.blocks,
+          pandoc.Blocks{pandoc.Para 'included'}
+        )
+      end),
+      test('sandbox disallows access to the filesystem', function ()
+        local tex = '\\include{lua/module/include.tex}'
+        local doc = pandoc.read(tex, 'latex', nil, {})
+        assert.are_equal(doc.blocks, pandoc.Blocks{})
+      end),
+      test('files can be added to the sandbox', function ()
+        local tex = '\\include{lua/module/include.tex}'
+        local doc = pandoc.read(tex, 'latex', nil, {'lua/module/include.tex'})
+        assert.are_equal(
+          doc.blocks,
+          pandoc.Blocks{pandoc.Para 'included'}
+        )
+      end),
+      test('sandbox files can be given as key-value pairs', function ()
+        local tex = '\\include{lua/module/include.tex}'
+        local files = {
+          ['lua/module/include.tex'] = 'Hello'
+        }
+        local doc = pandoc.read(tex, 'latex', nil, files)
+        assert.are_equal(
+          doc.blocks,
+          pandoc.Blocks{pandoc.Para 'Hello'}
+        )
+      end),
+      test('kv-pairs override contents read from file system', function ()
+        local tex = '\\include{lua/module/include.tex}'
+        local files = {
+          'lua/module/include.tex',
+          ['lua/module/include.tex'] = 'Hello'
+        }
+        local doc = pandoc.read(tex, 'latex', nil, files)
+        assert.are_equal(
+          doc.blocks,
+          pandoc.Blocks{pandoc.Para 'Hello'}
+        )
+      end),
+    },
     group 'extensions' {
       test('string spec', function ()
         local doc = pandoc.read('"vice versa"', 'markdown-smart')
Binary files old/pandoc-lua-engine-0.4.1.1/test/lua/module/sample.epub and 
new/pandoc-lua-engine-0.4.2/test/lua/module/sample.epub differ

Reply via email to