Lua: set module name before pushing

Using the correct module name is relevant when auto-generating
documentation.
This commit is contained in:
Albert Krewinkel 2022-02-05 13:29:45 +01:00
parent 3169367475
commit c962cef309
No known key found for this signature in database
GPG key ID: 388DC0B21F631124

View file

@ -16,6 +16,7 @@ module Text.Pandoc.Lua.Packages
) where
import Control.Monad (forM_)
import Data.String (fromString)
import Text.Pandoc.Error (PandocError)
import Text.Pandoc.Lua.Marshal.List (pushListModule)
import Text.Pandoc.Lua.PandocLua (PandocLua, liftPandocLua)
@ -60,8 +61,9 @@ pandocPackageSearcher pkgName =
_ -> reportPandocSearcherFailure
where
pushModuleLoader mdl = liftPandocLua $ do
let mdl' = mdl { Lua.moduleName = fromString pkgName }
Lua.pushHaskellFunction $
Lua.NumResults 1 <$ Lua.pushModule @PandocError mdl
Lua.NumResults 1 <$ Lua.pushModule mdl'
return (Lua.NumResults 1)
pushWrappedHsFun f = liftPandocLua $ do
Lua.pushHaskellFunction f