48,403
edits
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 11: | Line 11: | ||
[[Module:languages]] and its submodules | [[Module:languages]] and its submodules | ||
[[Module:gender and number]] | [[Module:gender and number]] | ||
]=] | ]=] | ||
local anchors_module = "Module:anchors" | local anchors_module = "Module:anchors" | ||
local gender_and_number_module = "Module:getn" | |||
local gender_and_number_module = "Module: | |||
local languages_module = "Module:languages" | local languages_module = "Module:languages" | ||
local load_module = "Module:load" | local load_module = "Module:load" | ||
| Line 49: | Line 47: | ||
anchor_encode = require(memoize_module)(mw.uri.anchorEncode, true) | anchor_encode = require(memoize_module)(mw.uri.anchorEncode, true) | ||
return anchor_encode(...) | return anchor_encode(...) | ||
end | end | ||
| Line 171: | Line 164: | ||
m_headword_data = load_data("Module:headword/data") | m_headword_data = load_data("Module:headword/data") | ||
return m_headword_data | return m_headword_data | ||
end | end | ||
| Line 236: | Line 221: | ||
--[==[Takes an input and splits on a double slash (taking account of escaping backslashes).]==] | --[==[Takes an input and splits on a double slash (taking account of escaping backslashes).]==] | ||
function export.split_on_slashes(text) | function export.split_on_slashes(text) | ||
text = split(escape(text, "//"), "//", true) or {} | text = split(escape(text, "//"), "//", true) or {} | ||
for i, v in ipairs(text) do | for i, v in ipairs(text) do | ||
| Line 302: | Line 284: | ||
--[==[Takes a link target and outputs the actual target and the fragment (if any).]==] | --[==[Takes a link target and outputs the actual target and the fragment (if any).]==] | ||
function export.get_fragment(text) | function export.get_fragment(text) | ||
-- If there are no embedded links, process input. | -- If there are no embedded links, process input. | ||
local open = find(text, "[[", nil, true) | local open = find(text, "[[", nil, true) | ||
| Line 336: | Line 315: | ||
if not target then | if not target then | ||
return nil | return nil | ||
end | end | ||
| Line 343: | Line 320: | ||
if target:sub(1, 1) == ":" then | if target:sub(1, 1) == ":" then | ||
-- FIXME, the auto_display (second return value) should probably remove the colon | -- FIXME, the auto_display (second return value) should probably remove the colon | ||
return target:sub(2), orig_target | return target:sub(2), orig_target | ||
| Line 407: | Line 383: | ||
return nil, orig_target | return nil, orig_target | ||
end | end | ||
target = "Reconstruction:" .. lang:getFullName() .. "/" .. target | |||
if not lang:hasType("conlang") then | |||
target = "Reconstruction:" .. lang:getFullName() .. "/" .. target | |||
end | |||
-- Reconstructed languages and substrates require an initial *. | -- Reconstructed languages and substrates require an initial *. | ||
elseif anti_asterisk ~= 1 and (lang:hasType("reconstructed") or lang:getFamilyCode() == "qfa-sub") then | elseif anti_asterisk ~= 1 and (lang:hasType("reconstructed") or lang:getFamilyCode() == "qfa-sub") then | ||
| Line 417: | Line 396: | ||
target = target | target = target | ||
end | end | ||
target = (lang:hasType("conlang") and "Contionary:" or "wikt:") .. target | |||
return target, orig_target, escaped > 0 | return target, orig_target, escaped > 0 | ||
end | end | ||
| Line 464: | Line 445: | ||
-- If `no_alt_ast` is true, use pcall to catch the error which will be thrown if this is a reconstructed lang and the alt text doesn't have *. | -- If `no_alt_ast` is true, use pcall to catch the error which will be thrown if this is a reconstructed lang and the alt text doesn't have *. | ||
if link.display == auto_display then | if link.display == auto_display then | ||
else | else | ||
local ok, check | local ok, check | ||
| Line 472: | Line 452: | ||
ok = true | ok = true | ||
check = export.get_link_page(orig_display, lang, sc, plain) | check = export.get_link_page(orig_display, lang, sc, plain) | ||
end | end | ||
end | end | ||
| Line 510: | Line 487: | ||
if prefix ~= "category" and not (prefix and load_data("Module:data/interwikis")[prefix]) then | if prefix ~= "category" and not (prefix and load_data("Module:data/interwikis")[prefix]) then | ||
if (link.fragment or link.target:sub(-1) == "#") and not plain then | if (link.fragment or link.target:sub(-1) == "#") and not plain then | ||
if cats then | if cats then | ||
insert(cats, lang:getFullName() .. " links with manual fragments") | insert(cats, lang:getFullName() .. " links with manual fragments") | ||
| Line 571: | Line 547: | ||
local function check_params_ignored_when_embedded(alt, lang, id, cats) | local function check_params_ignored_when_embedded(alt, lang, id, cats) | ||
if alt then | if alt then | ||
if cats then | if cats then | ||
insert(cats, lang:getFullName() .. " links with ignored alt parameters") | insert(cats, lang:getFullName() .. " links with ignored alt parameters") | ||
| Line 577: | Line 552: | ||
end | end | ||
if id then | if id then | ||
if cats then | if cats then | ||
insert(cats, lang:getFullName() .. " links with ignored id parameters") | insert(cats, lang:getFullName() .. " links with ignored id parameters") | ||
| Line 686: | Line 660: | ||
end | end | ||
term, alt = new_term, new_alt | term, alt = new_term, new_alt | ||
end | end | ||
end | end | ||
| Line 755: | Line 724: | ||
if type(data) ~= "table" then | if type(data) ~= "table" then | ||
error("The first argument to the function language_link must be a table. See Module:links/documentation for more information.") | error("The first argument to the function language_link must be a table. See Module:links/documentation for more information.") | ||
end | end | ||
| Line 781: | Line 748: | ||
if type(data) ~= "table" then | if type(data) ~= "table" then | ||
error("The first argument to the function plain_link must be a table. See Module:links/documentation for more information.") | error("The first argument to the function plain_link must be a table. See Module:links/documentation for more information.") | ||
end | end | ||
| Line 802: | Line 767: | ||
if type(data) ~= "table" then | if type(data) ~= "table" then | ||
error("The first argument to the function embedded_language_links must be a table. See Module:links/documentation for more information.") | error("The first argument to the function embedded_language_links must be a table. See Module:links/documentation for more information.") | ||
end | end | ||
| Line 832: | Line 795: | ||
tag = { '<span class="mention-gloss-double-quote">“</span><span class="mention-gloss">', | tag = { '<span class="mention-gloss-double-quote">“</span><span class="mention-gloss">', | ||
'</span><span class="mention-gloss-double-quote">”</span>' } | '</span><span class="mention-gloss-double-quote">”</span>' } | ||
elseif item_type == "tr" then | elseif item_type == "tr" then | ||
if face == "term" then | if face == "term" then | ||
| Line 1,124: | Line 1,082: | ||
* If <code class="n">show_qualifiers</code> is specified or the `show_qualifiers` field is set, left and right qualifiers, accent qualifiers, labels and references will be displayed, otherwise they will be ignored. (This is because a fair amount of code stores qualifiers, labels and/or references in these fields and displays them itself, rather than expecting {{code|lua|full_link()}} to display them.)]==] | * If <code class="n">show_qualifiers</code> is specified or the `show_qualifiers` field is set, left and right qualifiers, accent qualifiers, labels and references will be displayed, otherwise they will be ignored. (This is because a fair amount of code stores qualifiers, labels and/or references in these fields and displays them itself, rather than expecting {{code|lua|full_link()}} to display them.)]==] | ||
function export.full_link(data, face, allow_self_link, show_qualifiers) | function export.full_link(data, face, allow_self_link, show_qualifiers) | ||
-- Prevent data from being destructively modified. | -- Prevent data from being destructively modified. | ||
local data = shallow_copy(data) | local data = shallow_copy(data) | ||
| Line 1,133: | Line 1,088: | ||
error("The first argument to the function full_link must be a table. " | error("The first argument to the function full_link must be a table. " | ||
.. "See Module:links/documentation for more information.") | .. "See Module:links/documentation for more information.") | ||
end | end | ||
| Line 1,190: | Line 1,143: | ||
if not data.sc[i] then | if not data.sc[i] then | ||
data.sc[i] = best | data.sc[i] = best | ||
end | end | ||
| Line 1,264: | Line 1,210: | ||
if data.tr[1] then | if data.tr[1] then | ||
local full_code = lang:getFullCode() | local full_code = lang:getFullCode() | ||
end | end | ||
| Line 1,279: | Line 1,224: | ||
if automated_tr or data.tr_fail then | if automated_tr or data.tr_fail then | ||
local manual_tr = data.tr[1] | local manual_tr = data.tr[1] | ||
if (not manual_tr) or lang:overrideManualTranslit(data.sc[1]) then | if (not manual_tr) or lang:overrideManualTranslit(data.sc[1]) then | ||
| Line 1,388: | Line 1,322: | ||
if type(link) ~= "string" then | if type(link) ~= "string" then | ||
error("The first argument to section_link was a " .. type(link) .. ", but it should be a string.") | error("The first argument to section_link was a " .. type(link) .. ", but it should be a string.") | ||
end | end | ||