Skip to content

Commit e85023c

Browse files
committed
chore: Split out builtins for Pandoc scripts
1 parent d46bd3c commit e85023c

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

docsrc/cli.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ Option Meaning
8787
* ``rockspec`` - globals allowed in rockspecs, by default added for files ending with ``.rockspec``;
8888
* ``luacheckrc`` - globals allowed in Luacheck configs, by default added for files ending with ``.luacheckrc``;
8989
* ``ldoc`` - globals allowed in LDoc config, by default added for files named ``config.ld``;
90-
* ``pandoc`` - globals allowed in Pandoc Lua;
91-
* ``pandoc_filters`` - globals allowed in Pandoc Lua, subset specific to filters;
90+
* ``pandoc`` - globals allowed in Pandoc Lua in any context;
91+
* ``pandoc_filter`` - globals allowed in Pandoc Lua, subset specific to filters;
9292
* ``pandoc_custom`` - globals allowed in Pandoc Lua, subset specific to custom reader/writers;
93+
* ``pandoc_script`` - globals allowed in Pandoc Lua, subset specific to scripts;
9394
* ``sile`` - globals allowed in The SILE Typesetter and its package ecosystem;
9495
* ``none`` - no standard globals.
9596

src/luacheck/builtin_standards/init.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ builtin_standards.sile = {
345345
}
346346
}
347347

348-
builtin_standards.pandoc = pandoc.pandoc
348+
builtin_standards.pandoc = pandoc.all
349349
builtin_standards.pandoc_filter = pandoc.filter
350350
builtin_standards.pandoc_custom = pandoc.custom
351+
builtin_standards.pandoc_script = pandoc.script
351352

352353
builtin_standards.none = {}
353354

src/luacheck/builtin_standards/pandoc.lua

+15-9
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ end
1010

1111
local common = {
1212
read_globals = {
13+
"PANDOC_VERSION", "PANDOC_API_VERSION", "PANDOC_STATE",
1314
"pandoc", "lpeg", "re",
1415
},
15-
}
16-
17-
-- https://pandoc.org/lua-filters.html
18-
local filter = {
19-
read_globals = {
20-
"FORMAT", "PANDOC_READER_OPTIONS", "PANDOC_WRITER_OPTIONS", "PANDOC_VERSION", "PANDOC_API_VERSION",
21-
"PANDOC_SCRIPT_FILE", "PANDOC_STATE",
22-
},
2316
globals = {
2417
-- document types
2518
"Inlines", "Inline", "Blocks", "Block", "Meta", "Pandoc",
@@ -32,6 +25,13 @@ local filter = {
3225
},
3326
}
3427

28+
-- https://pandoc.org/lua-filters.html
29+
local filter = {
30+
read_globals = {
31+
"FORMAT", "PANDOC_READER_OPTIONS", "PANDOC_WRITER_OPTIONS", "PANDOC_SCRIPT_FILE"
32+
},
33+
}
34+
3535
-- https://pandoc.org/custom-readers.html
3636
-- https://pandoc.org/custom-writers.html
3737
local custom = {
@@ -44,10 +44,16 @@ local custom = {
4444
},
4545
}
4646

47+
local script = {
48+
globals = {
49+
}
50+
}
51+
4752
local variants = {
48-
pandoc = { globals = combine(common, filter, custom) },
53+
all = { globals = combine(common, filter, custom, script) },
4954
filter = { globals = combine(common, filter) },
5055
custom = { globals = combine(common, custom) },
56+
script = { globals = combine(common, script) },
5157
}
5258

5359
return variants

0 commit comments

Comments
 (0)