Module:links: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 217: Line 217:


-- Make a link from a given link's parts
-- Make a link from a given link's parts
local function make_link(link, lang, sc, id, isolated, plain, cats, no_alt_ast, to_wik)
local function make_link(link, lang, sc, id, isolated, plain, cats, no_alt_ast, to_wikt)
-- Convert percent encoding to plaintext.
-- Convert percent encoding to plaintext.
link.target = decode_uri(link.target, "PATH")
link.target = decode_uri(link.target, "PATH")
Line 319: Line 319:
link.fragment = link.fragment and encode_entities(remove_formatting(link.fragment), "#%&+/:<=>@[\\]_{|}")
link.fragment = link.fragment and encode_entities(remove_formatting(link.fragment), "#%&+/:<=>@[\\]_{|}")


return "[[" .. (to_wik and "wikt:" or "Contionary:") .. link.target .. (link.fragment and "#" .. link.fragment or "") .. "|" .. link.display .. "]]"
return "[[" .. (to_wikt and "wikt:" or "Contionary:") .. link.target .. (link.fragment and "#" .. link.fragment or "") .. "|" .. link.display .. "]]"
end
end


Line 503: Line 503:
text = text and trim(text)
text = text and trim(text)
data.alt = data.alt and trim(data.alt)
data.alt = data.alt and trim(data.alt)
return make_link({target = text, display = data.alt, fragment = data.fragment}, data.lang, data.sc, data.id, true, nil, data.cats, data.no_alt_ast, data.to_wik)
return make_link({target = text, display = data.alt, fragment = data.fragment}, data.lang, data.sc, data.id, true, nil, data.cats, data.no_alt_ast, data.to_wikt)
end
end


Line 756: Line 756:
* If <code class="n">no_alt_ast</code> is specified, then the alt text does not need to contain an asterisk if the language is reconstructed. This should only be used by modules which really need to allow links to reconstructions that don't display asterisks (e.g. number boxes).
* If <code class="n">no_alt_ast</code> is specified, then the alt text does not need to contain an asterisk if the language is reconstructed. This should only be used by modules which really need to allow links to reconstructions that don't display asterisks (e.g. number boxes).
* If <code class="n">show_qualifiers</code> is specified, left and right qualifiers and references will be displayed. (This is for compatibility reasons, since a fair amount of code stores qualifiers and/or references in these fields and displays them itself, expecting {{code|lua|full_link()}} to ignore them.]==]
* If <code class="n">show_qualifiers</code> is specified, left and right qualifiers and references will be displayed. (This is for compatibility reasons, since a fair amount of code stores qualifiers and/or references in these fields and displays them itself, expecting {{code|lua|full_link()}} to ignore them.]==]
function export.full_link(data, face, allow_self_link, show_qualifiers, to_wik)
function export.full_link(data, face, allow_self_link, show_qualifiers, to_wikt)
-- Prevent data from being destructively modified.
-- Prevent data from being destructively modified.
local data = shallowcopy(data)
local data = shallowcopy(data)
Line 910: Line 910:
cats = data.cats,
cats = data.cats,
no_alt_ast = data.no_alt_ast,
no_alt_ast = data.no_alt_ast,
to_wik = to_wik
to_wikt = to_wikt
}
}
link = require("Module:script utilities").tag_text(
link = require("Module:script utilities").tag_text(

Navigation menu