From cd91f72843359c5305842fa8afbec4a2d72629fa Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 17 Nov 2021 08:47:30 +0100 Subject: Lua: set `lpeg`, `re` as globals; allow shared lib access via require The `lpeg` and `re` modules are loaded into globals of the respective name, but they are not necessarily registered as loaded packages. This ensures that - the built-in library versions are preferred when setting the globals, - a shared library is used if pandoc has been compiled without `lpeg`, and - the `require` mechanism can be used to load the shared library if available, falling back to the internal version if possible and necessary. --- doc/lua-filters.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 38790ca5d..9fc90a13f 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -253,17 +253,26 @@ variables. `lpeg` : This variable holds the `lpeg` module, a package based on - Parsing Expression Grammars (PEG). It provides excellent + Parsing Expression Grammars (PEG). It provides excellent parsing utilities and is documented on the official [LPeg - homepage]. Pandoc will try to load the module through the - normal package mechanism, and fall back to a built-in version - if necessary. + homepage]. Pandoc uses a built-int version of the library, + unless it has been configured by the package maintainer to + rely on a system-wide installation. + + Note that the result of `require 'lpeg'` is not necessarily + equal to this value; the `require` mechanism prefers the + system's lpeg library over the built-in version. `re` -: Contains the LPeg.re module, which is built on top of LPeg and - offers an implementation of a [regex engine]. Pandoc will try - to load the module through the normal package mechanism, and - fall back to a built-in version if necessary. +: Contains the LPeg.re module, which is built on top of LPeg + and offers an implementation of a [regex engine]. Pandoc + uses a built-in version of the library, unless it has been + configured by the package maintainer to rely on a system-wide + installation. + + Note that the result of `require 're` is not necessarily + equal to this value; the `require` mechanism prefers the + system's lpeg library over the built-in version. [LPeg homepage]: http://www.inf.puc-rio.br/~roberto/lpeg/ [regex engine]: http://www.inf.puc-rio.br/~roberto/lpeg/re.html -- cgit v1.2.3