Modul:links: Redaktələr arasındakı fərq

Silinən məzmun Əlavə edilmiş məzmun
Redaktənin izahı yoxdur
Redaktənin izahı yoxdur
 
Sətir 43:
}
 
local unsupported_titles
function export.getLinkPage(target, lang)
ifunsupported_titles = unsupported_titles or mw.loadData("Module:links/data").unsupported_titles[target] then
return if "Unsupported titles/" .. mw.loadData("Module:links/data").unsupported_titles[target] then
return "Unsupported titles/" .. unsupported_titles[target]
end
-- If the link contains unexpanded template parameters, then don't create a link.
if target:find("{{{", nil, true) then
return nil
end
Sətir 59 ⟶ 61:
-- Remove diacritics from the page name
target = lang:makeEntryName(target)
if target:sub(1, 1) == "/" then
return ":" .. target
-- Link to appendix for reconstructed terms and terms in appendix-only languages
ifelseif target:findsub(1, 1) == "^*.") and #target > 1 then
if lang:getCode() == "und" then
return nil
Sətir 68 ⟶ 73:
target = "Reconstruction:" .. lang:getCanonicalName() .. "/" .. usub(target, 2)
elseif lang:getType() == "reconstructed" then
error("The specified language " .. lang:getCanonicalName()
.. " is unattested, while the given word is not marked with '*' to indicate that it is reconstructed")
elseif lang:getType() == "appendix-constructed" then
target = "Appendix:" .. lang:getCanonicalName() .. "/" .. target
Sətir 79 ⟶ 85:
local function makeLangLink(link, lang, id, allowSelfLink)
-- Temporary tracking code
local langCode = lang:getCode()
if (lang:getCode() == "sma" or lang:getCode() == "sju" or lang:getCode() == "sje" or lang:getCode() == "smj" or lang:getCode() == "se" or lang:getCode() == "smn" or lang:getCode() == "sia" or lang:getCode() == "sjk" or lang:getCode() == "sms" or lang:getCode() == "sjd" or lang:getCode() == "sjt") then
if langCode == "se" or langCode == "sia" or langCode:find("^sm[ajns]$")
if link.display and string.find(link.display, "'") then
or langCode:find("^sj[dektu]$") then
if link.display and stringlink.display:find(link.display, "'") then
require("Module:debug").track("links/Sami apostrophe display")
elseif link.target and stringlink.target:find(link.target, "'") then
require("Module:debug").track("links/Sami apostrophe target")
end
Sətir 91 ⟶ 99:
if link.fragment == nil then
-- Replace numeric character references with the corresponding character ( → '),
-- as they contain #, which wouldcauses bethe misinterpretednumeric (wa'acharacter reference waato → pagename wa&, fragment 29;a).be
-- misparsed (wa'a → waa → pagename wa&, fragment 29;a).
link.target = link.target:gsub("&#(%d+);",
function(number) return mw.ustring.char(tonumber(number)) end)
Sətir 128 ⟶ 137:
end
-- If the target is the same as the current page, thenand returnthere ais "self-link"no likesense the software doesid
-- and linking to the same page hasn't been turned on, then return a "self-link"
if not allowSelfLink and not id and (link.target == mw.title.getCurrentTitle().prefixedText or link.target == ":" .. mw.title.getCurrentTitle().prefixedText) then
-- like the software does.
if not (allowSelfLink and notor id) and (link.target:gsub("^:", == mw.title.getCurrentTitle("").prefixedText or link.target == ":" .. mw.title.getCurrentTitle().prefixedText) then
return "<strong class=\"selflink\">" .. link.display .. "</strong>"
end
Sətir 147 ⟶ 158:
}
if not (prefix and prefixes[prefix]) then
if link.fragment or link.target:find("#$") then
require("Module:debug").track {
Sətir 158 ⟶ 169:
if id then
link.fragment = require("Module:utilities").make_id(lang, id)
elseif not mw.ustring.find(link.target, "^Appendix:")
and not mw.ustring.find(link.target, "^Reconstruction:") then
link.fragment = lang:getCanonicalName()
end
Sətir 167 ⟶ 179:
end
return "[[" .. link.target .. (link.fragment and "#" .. link.fragment or "") .. "|" .. link.display .. "]]"
end
 
Sətir 227 ⟶ 239:
if data.alt then
require("Module:debug").track("links/alt-ignored")
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
"ignored alt:", data.alt, "lang:", data.lang:getCode())
end
if data.id then
require("Module:debug").track("links/id-ignored")
mw.log("(from Module:links)", "text with embedded wikilinks:", text,
"ignored id:", data.id, "lang:", data.lang:getCode())
end
Sətir 279 ⟶ 293:
if itemType == "gloss" then
tag = { '<span class="mention-gloss-double-quote">“</span><span class="mention-gloss">',
'</span><span class="mention-gloss-double-quote">”</span>' }
elseif itemType == "tr" then
if face == "term" then
tag = { '<span lang="' .. lang:getCode() .. '" class="tr mention-tr Latn">',
'</span>' }
else
tag = { '<span lang="' .. lang:getCode() .. '" class="tr Latn">', '</span>' }
Sətir 288 ⟶ 304:
elseif itemType == "ts" then
tag = { '<span class="ts mention-ts Latn">/', '/</span>' }
elseif itemType == "pos" then
tag = { '<span class="ann-pos">', '</span>' }
elseif itemType == "annotations" then
tag = { '<span class="mention-gloss-paren annotation-paren">(</span>',
'<span class="mention-gloss-paren annotation-paren">)</span>' }
end
Sətir 330 ⟶ 349:
if data.tr and data.ts then
table_insert(annotations,
require("Module:script utilities").tag_translit(data.tr, data.lang, kind)
.. " " .. export.mark(data.ts, "ts"))
elseif data.ts then
table_insert(annotations, export.mark(data.ts, "ts"))
else
table_insert(annotations,
require("Module:script utilities").tag_translit(data.tr, data.lang, kind))
end
end
Sətir 345 ⟶ 367:
-- Part of speech
if data.pos then
table_insert(annotations, pos_tags[data.pos] or data.pos)
-- debug category for pos= containing transcriptions
if mw.ustring.match(data.pos, :find("/[^><]*/") ~= nil then
table_insert(annotations,data.pos = data.pos .. "[[Category:links likely containing transcriptions in pos]]")
end
 
table_insert(annotations, export.mark(pos_tags[data.pos] or data.pos, "pos"))
end
Sətir 367 ⟶ 390:
function export.full_link(data, face, allowSelfLink, dontLinkRecons)
if type(data) ~= "table" then
error("The first argument to the function full_link must be a table. "
.. "See Module:links/documentation for more information.")
end
Sətir 400 ⟶ 424:
if data.accel then
local accel
class = "form-of lang-" .. data.lang:getCode() .. " " .. data.accel
if type(data.accel) == "table" then
local form, gender, translit, lemma, lemma_translit, no_store
form = data.accel.form and data.accel.form .. "-form-of" or ""
gender = data.accel.gender and "gender-" .. data.accel.gender or ""
translit = data.accel.translit and "transliteration-" .. data.accel.translit or ""
-- This is decoded again by [[WT:ACCEL]].
lemma = data.accel.lemma and "origin-" .. data.accel.lemma:gsub("%%", "."):gsub(" ", "_") or ""
lemma_translit = data.accel.lemma_translit and "origin-transliteration-" .. data.accel.lemma_translit or ""
no_store = data.accel.no_store and "form-of-nostore" or ""
accel =
form .. " " ..
gender .. " " ..
translit .. " " ..
lemma .. " " ..
lemma_translit .. " " ..
no_store .. " "
else
accel = data.accel
require("Module:debug").track("links/accel not table")
require("Module:debug").track("links/accel not table/" .. data.lang:getCode())
end
class = "form-of lang-" .. data.lang:getCode() .. " " .. data.accel
end
-- Only make a link if the term has been given, otherwise just show the alt text without a link
link = require("Module:script utilities").tag_text(
data.term and export.language_link(data, allowSelfLink, dontLinkRecons)
or data.alt, data.lang, data.sc, face, class)
else
--[[ No term to show.
Sətir 431 ⟶ 481:
data.tr = data.tr or m_phonetic.getTranslit(export.remove_links(data.term))
elseif (data.term or data.alt) and not data.sc:getCode():find("Lati?n") then
and not ((data.sc:getCode():find("Latn", nil, true)) or data.sc:getCode() == "Latinx") then
-- Try to generate a transliteration, ifunless necessarytransliteration has been
if not mw.loadData("Module:links/data").high_memory_entries[mw.title.getCurrentTitle().text] or not data.tr then
-- supplied and we are in a high-memory entry.
-- Try to generate a transliteration if necessary
if not (data.tr and mw.loadData("Module:links/data").high_memory_entries[mw.title.getCurrentTitle().text] or not data.tr) then
local automated_tr = data.lang:transliterate(export.remove_links(data.alt or data.term), data.sc)
Sətir 582 ⟶ 632:
section = decodeAnchor(section)
return-- table_concatURI-encode { "[[", page, "#",(percent-encode) section, "|",to page,allow "square § "brackets, section[], "]]" }
-- in section name. If not percent-encoded, they prevent the parser from
-- recognizing the link.
return table_concat { "[[", page, "#", mw.uri.encode(section, "WIKI"), "|", page, " § ", section, "]]" }
else
error('The function "' .. section_link .. '" could not find a number sign marking a section name.')