diff --git a/docsrc/cli.rst b/docsrc/cli.rst index f8e6685a..93e1d3b2 100644 --- a/docsrc/cli.rst +++ b/docsrc/cli.rst @@ -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. diff --git a/src/luacheck/builtin_standards/init.lua b/src/luacheck/builtin_standards/init.lua index 377d88d4..fc7698fe 100644 --- a/src/luacheck/builtin_standards/init.lua +++ b/src/luacheck/builtin_standards/init.lua @@ -345,9 +345,10 @@ builtin_standards.sile = { } } -builtin_standards.pandoc = pandoc.pandoc +builtin_standards.pandoc = pandoc.all builtin_standards.pandoc_filter = pandoc.filter builtin_standards.pandoc_custom = pandoc.custom +builtin_standards.pandoc_script = pandoc.script builtin_standards.none = {} diff --git a/src/luacheck/builtin_standards/pandoc.lua b/src/luacheck/builtin_standards/pandoc.lua index d7b062f3..4f046a40 100644 --- a/src/luacheck/builtin_standards/pandoc.lua +++ b/src/luacheck/builtin_standards/pandoc.lua @@ -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", @@ -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 = { @@ -44,10 +44,16 @@ local custom = { }, } +local script = { + globals = { + } +} + local variants = { - pandoc = { globals = combine(common, filter, custom) }, + all = { globals = combine(common, filter, custom, script) }, filter = { globals = combine(common, filter) }, custom = { globals = combine(common, custom) }, + script = { globals = combine(common, script) }, } return variants