Module:form of/data: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Replaced content with "local export = {} local ipairs = ipairs local next = next local type = type export.TAG_TYPE = 1 export.GLOSSARY = 2 local SHORTCUTS = 3; export.SHORTCUTS = SHORTCUTS export.WIKIDATA = 4 export.APPENDIX = true export.WIKT = 0 export.WP = false local function process_shortcut(tags, shortcuts, name, shortcut) -- If the shortcut is already in the list, then there is a duplicate. if shortcuts[shortcut] then error("The shortcut \"" .. shortcut .. "\" (for the infle...") Tag: Replaced |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local export = {} | |||
local ipairs = ipairs | |||
local next = next | |||
local type = type | |||
export.TAG_TYPE = 1 | |||
export.GLOSSARY = 2 | |||
local SHORTCUTS = 3; export.SHORTCUTS = SHORTCUTS | |||
export.WIKIDATA = 4 | |||
export.APPENDIX = true | |||
export.WIKT = 0 | |||
export.WP = false | |||
local function process_shortcut(tags, shortcuts, name, shortcut) | |||
-- If the shortcut is already in the list, then there is a duplicate. | |||
if shortcuts[shortcut] then | |||
error("The shortcut \"" .. shortcut .. "\" (for the inflection tag \"" .. name .. "\") conflicts with an existing shortcut for the tag \"" .. shortcuts[shortcut] .. "\".") | |||
elseif tags[shortcut] then | |||
error("The shortcut \"" .. shortcut .. "\" (for the inflection tag \"" .. name .. "\") conflicts with an existing tag with that name.") | |||
end | |||
shortcuts[shortcut] = name | |||
end | |||
shortcuts | |||
tags[ | |||
shortcuts | |||
function export.finalize(tags, shortcuts) | |||
for name, data in next, tags do | |||
local data_shortcuts = data[SHORTCUTS] | |||
if data_shortcuts then | |||
if type(data_shortcuts) == "string" then | |||
process_shortcut(tags, shortcuts, name, data_shortcuts) | |||
else | |||
for _, shortcut in ipairs(data_shortcuts) do | |||
process_shortcut(tags, shortcuts, name, shortcut) | |||
end | |||
tags | |||
tags | |||
tags | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return | return export | ||
Latest revision as of 13:16, 12 January 2025
- The following documentation is located at Module:form of/data/doc.[edit]
- Useful links: root page • root page's subpages • links • transclusions • testcases • sandbox
local export = {}
local ipairs = ipairs
local next = next
local type = type
export.TAG_TYPE = 1
export.GLOSSARY = 2
local SHORTCUTS = 3; export.SHORTCUTS = SHORTCUTS
export.WIKIDATA = 4
export.APPENDIX = true
export.WIKT = 0
export.WP = false
local function process_shortcut(tags, shortcuts, name, shortcut)
-- If the shortcut is already in the list, then there is a duplicate.
if shortcuts[shortcut] then
error("The shortcut \"" .. shortcut .. "\" (for the inflection tag \"" .. name .. "\") conflicts with an existing shortcut for the tag \"" .. shortcuts[shortcut] .. "\".")
elseif tags[shortcut] then
error("The shortcut \"" .. shortcut .. "\" (for the inflection tag \"" .. name .. "\") conflicts with an existing tag with that name.")
end
shortcuts[shortcut] = name
end
function export.finalize(tags, shortcuts)
for name, data in next, tags do
local data_shortcuts = data[SHORTCUTS]
if data_shortcuts then
if type(data_shortcuts) == "string" then
process_shortcut(tags, shortcuts, name, data_shortcuts)
else
for _, shortcut in ipairs(data_shortcuts) do
process_shortcut(tags, shortcuts, name, shortcut)
end
end
end
end
end
return export