Module:columns: Difference between revisions

No edit summary
No edit summary
 
Line 66: Line 66:
end
end


local function full_link_and_track_self_links(item, face)
local function full_link_and_track_self_links(item, face, nochecktr)
if item.term then
if item.term then
local pagename = mw.loadData(headword_data_module).pagename
local pagename = mw.loadData(headword_data_module).pagename
Line 75: Line 75:
if current_L2 then
if current_L2 then
local current_L2_lang = require(languages_module).getByCanonicalName(current_L2)
local current_L2_lang = require(languages_module).getByCanonicalName(current_L2)
if current_L2_lang and current_L2_lang:getCode() == item.lang:getCode() then
if term_is_pagename then
track("term-is-pagename")
else
track("term-contains-pagename")
end
end
end
end
end
end
Line 87: Line 80:


item.suppress_redundant_wikilink_cat = suppress_redundant_wikilink_cat
item.suppress_redundant_wikilink_cat = suppress_redundant_wikilink_cat
item.never_call_transliteration_module = nochecktr
return require(links_module).full_link(item, face)
return require(links_module).full_link(item, face)
end
end


local function format_subitem(subitem, lang, face, compute_embedded_comma)
local function format_subitem(subitem, lang, face, compute_embedded_comma, nochecktr)
local embedded_comma = false
local embedded_comma = false
local text
local text
Line 99: Line 93:
end
end
else
else
text = full_link_and_track_self_links(subitem, face)
text = full_link_and_track_self_links(subitem, face, nochecktr)
if compute_embedded_comma then
if compute_embedded_comma then
-- We don't check qualifier, label or reference text for commas as it's inside parens or displayed
-- We don't check qualifier, label or reference text for commas as it's inside parens or displayed
Line 128: Line 122:
local compute_embedded_comma = args.horiz == "comma"
local compute_embedded_comma = args.horiz == "comma"
local embedded_comma = false
local embedded_comma = false
local nochecktr = args.noautotr
if type(item) == "table" then
if type(item) == "table" then
if item.terms then
if item.terms then
Line 144: Line 139:
end
end
local formatted, this_embedded_comma = format_subitem(subitem, args.lang, face,
local formatted, this_embedded_comma = format_subitem(subitem, args.lang, face,
compute_embedded_comma)
compute_embedded_comma, nochecktr)
embedded_comma = embedded_comma or this_embedded_comma
embedded_comma = embedded_comma or this_embedded_comma
insert(parts, formatted)
insert(parts, formatted)
Line 152: Line 147:
return concat(parts), embedded_comma
return concat(parts), embedded_comma
else
else
return format_subitem(item, args.lang, face, compute_embedded_comma)
return format_subitem(item, args.lang, face, compute_embedded_comma, nochecktr)
end
end
else
else
Line 159: Line 154:
end
end
if args.lang and not term_already_linked(item) then
if args.lang and not term_already_linked(item) then
return full_link_and_track_self_links({lang = args.lang, term = item, sc = args.sc}, face), embedded_comma
return full_link_and_track_self_links({lang = args.lang, term = item, sc = args.sc}, face, nochecktr), embedded_comma
else
else
return item, embedded_comma
return item, embedded_comma
Line 361: Line 356:
local keepfirst = args.keepfirst or 0
local keepfirst = args.keepfirst or 0
local keeplast = args.keeplast or 0
local keeplast = args.keeplast or 0
if keepfirst > 0 then
track("keepfirst")
end
if keeplast > 0 then
track("keeplast")
end


-- maybe construct old-style header
-- maybe construct old-style header
Line 644: Line 633:
-- (no columns, no collapsbility).
-- (no columns, no collapsbility).
["minrows"] = {type = "number", default = 5},
["minrows"] = {type = "number", default = 5},
-- Disables automatic transliteration; entries without a manual transliteration will have none at all.
-- Used on large pages, especially Chinese ones, because zh-translit works by fetching and parsing
-- the target of the page, which is a performance killer on large pages with potentially thousands
-- of link targets.
-- Note: noautotr also disables redundant transliteration checks.
["noautotr"] = boolean,
}
}


Line 696: Line 691:
["horiz"] = {},
["horiz"] = {},
["notr"] = boolean,
["notr"] = boolean,
["noautotr"] = boolean,
["allow_space_delim"] = boolean,
["allow_space_delim"] = boolean,
["tilde_delim"] = {},
["tilde_delim"] = {},
Line 785: Line 781:
local sort = iargs.sort
local sort = iargs.sort
if args.sort ~= nil then
if args.sort ~= nil then
if not args.sort then
track("nosort")
end
sort = args.sort
sort = args.sort
else
else
Line 802: Line 795:
local collapse = iargs.collapse
local collapse = iargs.collapse
if args.collapse ~= nil then
if args.collapse ~= nil then
if not args.collapse then
track("nocollapse")
end
collapse = args.collapse
collapse = args.collapse
end
end
Line 823: Line 813:
if args.notr then
if args.notr then
item.tr = "-"
item.tr = "-"
elseif args.noautotr then
item.tr = item.tr or "-"
end
end


Line 901: Line 893:
keeplast = args.keeplast,
keeplast = args.keeplast,
horiz = args.horiz,
horiz = args.horiz,
noautotr = args.noautotr,
} .. (horiz_edit_button or "") .. (formatted_cats or "")
} .. (horiz_edit_button or "") .. (formatted_cats or "")
end
end