Module:gloss: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) No edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
Line 19: | Line 19: | ||
if l then l_gloss = type(l.glossary) == "string" and l.glossary or l.label end | if l then l_gloss = type(l.glossary) == "string" and l.glossary or l.label end | ||
-- format hover | -- format hover | ||
glosslet_format = frame:expandTemplate{title = "hover", args = {glosslet_format, l_gloss, noline = args.noline or (args.style == nil and l and args. | glosslet_format = frame:expandTemplate{title = "hover", args = {glosslet_format, l_gloss, noline = args.noline or (args.style == nil and l and args.nolinks == nil), style = args.style}} | ||
if l and args. | if l and args.nolinks == nil then glosslet_format = "[[Appendix:Glossary#" .. l_gloss .. "|" .. glosslet_format .. "]]" end | ||
-- format links (hover and links MUST be in this order) | -- format links (hover and links MUST be in this order) | ||
end | end |
Revision as of 20:26, 17 April 2025
Underlies {{gloss}}
, as well as Module:gloss grid. Uses Module:form of/data.
local export = {}
local getArgs = require('Module:Arguments').getArgs
local m_data = mw.loadData("Module:form of/data")
local delimiters = "%s%p"
function export.show(frame)
local args = getArgs(frame)
local gloss = args[1]
local gloss_keys = {}
for glosslet in gloss:gmatch("[^" .. delimiters .. "]+") do
if glosslet:match("^[%d%u]+$") then
local gloss_code = glosslet:lower()
local glosslet_format = gloss_code:gsub("(%d+)", "<small>%1</small>")
if m_data.aliases[gloss_code] then
local l_gloss = m_data.aliases[gloss_code]
local l = m_data.labels[l_gloss]
if l then l_gloss = type(l.glossary) == "string" and l.glossary or l.label end
-- format hover
glosslet_format = frame:expandTemplate{title = "hover", args = {glosslet_format, l_gloss, noline = args.noline or (args.style == nil and l and args.nolinks == nil), style = args.style}}
if l and args.nolinks == nil then glosslet_format = "[[Appendix:Glossary#" .. l_gloss .. "|" .. glosslet_format .. "]]" end
-- format links (hover and links MUST be in this order)
end
gloss_keys[glosslet] = '<span style="font-variant: small-caps">' .. glosslet_format .. '</span>'
end
end
for search, replace in pairs(gloss_keys) do gloss = gloss:gsub(search, replace) end
return gloss
end
return export
--[[
=p.show(mw.getCurrentFrame():newChild{title="whatever",args={"sheep-NOM.SG 3S.ANIM-DAT;SG wool-GEN.SG NEG.PST-DISJ=SG Radestria.DAT | "}})
]]--