Last active
April 26, 2024 14:55
-
-
Save tarleb/ef63974ab18d92acf0eb40180d832c48 to your computer and use it in GitHub Desktop.
list-formats.lua
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
--- Lists the formats that support all the extensions given on the command line. | |
-- | |
-- Usage: | |
-- | |
-- pandoc lua list-formats.lua [extensions,...] | |
-- | |
-- Example: | |
-- | |
-- $ pandoc lua list-formats.lua native_numbering citations | |
-- docx | |
-- | |
-- Create a sorted list of all known formats. | |
local formats = pandoc.List{} | |
for fmt in pairs(pandoc.readers) do | |
formats:insert(fmt) | |
end | |
for fmt in pairs(pandoc.writers) do | |
if not formats:includes(fmt) then | |
formats:insert(fmt) | |
end | |
end | |
formats:sort() | |
-- Iterate over all known formats, and print those that support *all* | |
-- given extensions. | |
for i, format in ipairs(formats) do | |
for j, ext in ipairs(arg) do | |
if not pandoc.format.all_extensions(format):includes(ext) then | |
goto continue | |
end | |
end | |
print(format) | |
::continue:: | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment