Skip to content

Commit

Permalink
Lua: include lpeg module
Browse files Browse the repository at this point in the history
Compiles the 'lpeg' library (Parsing Expression Grammars For Lua) into
the program.

Package maintainers may choose to rely on package dependencies to make
lpeg available, in which case they can compile the with the constraint
`lpeg +rely-on-shared-lpeg-library`.
  • Loading branch information
tarleb committed Oct 31, 2021
1 parent 3de8f4f commit e693c70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ library
http-types >= 0.8 && < 0.13,
ipynb >= 0.1.0.2 && < 0.2,
jira-wiki-markup >= 1.4 && < 1.5,
lpeg >= 1.0 && < 1.1,
mtl >= 2.2 && < 2.3,
network >= 2.6,
network-uri >= 2.6 && < 2.8,
Expand Down
6 changes: 5 additions & 1 deletion src/Text/Pandoc/Lua/Packages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Text.Pandoc.Lua.PandocLua (PandocLua, liftPandocLua, loadDefaultModule)
import qualified HsLua as Lua
import qualified HsLua.Module.Path as Path
import qualified HsLua.Module.Text as Text
import qualified Lua.LPeg as LPeg
import qualified Text.Pandoc.Lua.Module.Pandoc as Pandoc
import qualified Text.Pandoc.Lua.Module.MediaBag as MediaBag
import qualified Text.Pandoc.Lua.Module.System as System
Expand All @@ -35,6 +36,9 @@ installPandocPackageSearcher = liftPandocLua $ do
shiftArray
Lua.pushHaskellFunction $ Lua.toHaskellFunction pandocPackageSearcher
Lua.rawseti (Lua.nth 2) 1
-- add lpeg searcher as last searcher
Lua.pushHaskellFunction $ Lua.state >>= Lua.liftIO . LPeg.lpeg_searcher
Lua.rawseti (Lua.nth 2) 6
Lua.pop 1 -- remove 'package.searchers' from stack
where
shiftArray = forM_ [4, 3, 2, 1] $ \i -> do
Expand Down Expand Up @@ -64,5 +68,5 @@ pandocPackageSearcher pkgName =
Lua.pushHaskellFunction f
return 1
reportPandocSearcherFailure = liftPandocLua $ do
Lua.push ("\n\t" <> pkgName <> "is not one of pandoc's default packages")
Lua.push ("\n\t" <> pkgName <> " is not one of pandoc's default packages")
return (Lua.NumResults 1)
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extra-deps:
- doctemplates-0.10
- emojis-0.1.2
- doclayout-0.3.1.1
- lpeg-1.0.0
- hslua-2.0.0
- hslua-classes-2.0.0
- hslua-core-2.0.0
Expand Down

0 comments on commit e693c70

Please sign in to comment.