forked from mpeterv/luacheck
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move pandoc builtins to their own module and split filters, rea…
…ders, and writers
- Loading branch information
Showing
3 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
local add_std_table = require "luacheck.standards".add_std_table | ||
|
||
local function combine(...) | ||
local res = {} | ||
for _, def in ipairs({...}) do | ||
add_std_table(res, def) | ||
end | ||
return res.fields | ||
end | ||
|
||
local common = { | ||
read_globals = { | ||
"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 = { | ||
-- - top level | ||
"Inlines", "Inline", "Blocks", "Block", "Meta", "Pandoc", | ||
-- - inline | ||
"Cite", "Code", "Emph", "Image", "LineBreak", "Link", "Math", "Note", "Quoted", "RawInline", "SmallCaps", | ||
"SoftBreak", "Space", "Span", "Str", "Strikeout", "Strong", "Subscript", "Superscript", "Underline", | ||
-- - block | ||
"BlockQuote", "BulletList", "CodeBlock", "DefinitionList", "Div", "Figure", "Header", "HorizontalRule", | ||
"LineBlock", "OrderedList", "Para", "Plain", "RawBlock", "Table", | ||
}, | ||
} | ||
|
||
-- https://pandoc.org/custom-readers.html | ||
local reader = { | ||
globals = { | ||
"Reader", "Extensions", | ||
"ByteStringReader" | ||
}, | ||
} | ||
|
||
-- https://pandoc.org/custom-writers.html | ||
local writer = { | ||
globals = { | ||
"PANDOC_DOCUMENT", "Writer", "Extensions", "Doc", "Template", | ||
"Blocksep", "ByteStringWriter", "CaptionedImage", "DisplayMath", "DoubleQuoted", "InlineMath", "SingleQuoted", | ||
}, | ||
} | ||
|
||
local variants = { | ||
pandoc = { globals = combine(common, filter, reader, writer) }, | ||
filter = { globals = combine(common, filter) }, | ||
reader = { globals = combine(common, reader) }, | ||
writer = { globals = combine(common, writer) }, | ||
} | ||
|
||
return variants |