Skip to content

Commit

Permalink
chore: Split out builtins for Pandoc scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 28, 2024
1 parent d46bd3c commit 680f236
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
5 changes: 3 additions & 2 deletions docsrc/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ Option Meaning
* ``rockspec`` - globals allowed in rockspecs, by default added for files ending with ``.rockspec``;
* ``luacheckrc`` - globals allowed in Luacheck configs, by default added for files ending with ``.luacheckrc``;
* ``ldoc`` - globals allowed in LDoc config, by default added for files named ``config.ld``;
* ``pandoc`` - globals allowed in Pandoc Lua;
* ``pandoc_filters`` - globals allowed in Pandoc Lua, subset specific to filters;
* ``pandoc`` - globals allowed in Pandoc Lua in any context;
* ``pandoc_filter`` - globals allowed in Pandoc Lua, subset specific to filters;
* ``pandoc_custom`` - globals allowed in Pandoc Lua, subset specific to custom reader/writers;
* ``pandoc_script`` - globals allowed in Pandoc Lua, subset specific to scripts;
* ``sile`` - globals allowed in The SILE Typesetter and its package ecosystem;
* ``none`` - no standard globals.

Expand Down
1 change: 1 addition & 0 deletions src/luacheck/builtin_standards/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ builtin_standards.sile = {
builtin_standards.pandoc = pandoc.pandoc
builtin_standards.pandoc_filter = pandoc.filter
builtin_standards.pandoc_custom = pandoc.custom
builtin_standards.pandoc_script = pandoc.script

builtin_standards.none = {}

Expand Down
24 changes: 15 additions & 9 deletions src/luacheck/builtin_standards/pandoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ end

local common = {
read_globals = {
"PANDOC_VERSION", "PANDOC_API_VERSION", "PANDOC_STATE",
"pandoc", "lpeg", "re",
},
}

-- https://pandoc.org/lua-filters.html
local filter = {
read_globals = {
"FORMAT", "PANDOC_READER_OPTIONS", "PANDOC_WRITER_OPTIONS", "PANDOC_VERSION", "PANDOC_API_VERSION",
"PANDOC_SCRIPT_FILE", "PANDOC_STATE",
},
globals = {
-- document types
"Inlines", "Inline", "Blocks", "Block", "Meta", "Pandoc",
Expand All @@ -32,6 +25,13 @@ local filter = {
},
}

-- https://pandoc.org/lua-filters.html
local filter = {
read_globals = {
"FORMAT", "PANDOC_READER_OPTIONS", "PANDOC_WRITER_OPTIONS", "PANDOC_SCRIPT_FILE"
},
}

-- https://pandoc.org/custom-readers.html
-- https://pandoc.org/custom-writers.html
local custom = {
Expand All @@ -44,10 +44,16 @@ local custom = {
},
}

local script = {
globals = {
}
}

local variants = {
pandoc = { globals = combine(common, filter, custom) },
pandoc = { globals = combine(common, filter, custom, script) },
filter = { globals = combine(common, filter) },
custom = { globals = combine(common, custom) },
script = { globals = combine(common, script) },
}

return variants

0 comments on commit 680f236

Please sign in to comment.