Modul:Redirect hatnote: Unterschied zwischen den Versionen

add kerning for redir titles beginning or ending with apostrophes or quotation marks, as at Neighbourhood and Kurtis Blow
(Updated module from sandbox. Removes dependency on Module:Redirect, and introduces more fine-grained categorization for redirect problems.)
(add kerning for redir titles beginning or ending with apostrophes or quotation marks, as at Neighbourhood and Kurtis Blow)
Zeile 59: Zeile 59:
local formattedRedirect = {}
local formattedRedirect = {}
for k,v in pairs(redirect) do
for k,v in pairs(redirect) do
formattedRedirect[k] = '"' .. v .. '"'
formattedRedirect[k] = p._quote(v)
end
end
local text = {
local text = {
Zeile 119: Zeile 119:


return mHatnote._hatnote(text, mhOptions) .. category
return mHatnote._hatnote(text, mhOptions) .. category
end
function p._quote(title)
local quotationMarks = {["'"]=true, ['"']=true, ['“']=true, ["‘"]=true, ['”']=true, ["’"]=true}
local style = ""
-- If string starts with anything in quotationMarks, kern to same degree {{-'}} does
if quotationMarks[string.sub(title, 1, 1)] then
style = "padding-left:0.15em;"
end
-- Likewise if it ends with any of them
if quotationMarks[string.sub(title, -1, -1)] then
style = style .. "padding-right:0.15em;"
end
return style ~= "" and '"<span style="' .. style .. '">' .. title .. '</span>"' or '"' .. title .. '"'
end
end
   
   
return p
return p
Anonymer Benutzer