Module:links: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 311: Line 311:
link.display = "]" .. link.display .. "["
link.display = "]" .. link.display .. "["
end
end
 
link.fragment = link.fragment and encode_entities(remove_formatting(link.fragment), "#%&+/:<=>@[\\]_{|}")
link.target = link.target:gsub("^(:?)(.*)", function(m1, m2)
link.target = link.target:gsub("^(:?)(.*)", function(m1, m2)
return m1 .. encode_entities(m2, "#%&+/:<=>@[\\]_{|}")
return m1 .. encode_entities(m2, "#%&+/:<=>@[\\]_{|}")
end)
end)
link.fragment = "#" .. lang:getCanonicalName()
if link.target:match("^%*") and lang:hasType("reconstructed") then
if link.target:match("^%*") and lang:hasType("reconstructed") then
link.target = link.target:gsub("^%*","Reconstruction:" .. lang:getCanonicalName() .. "/")
link.target = link.target:gsub("^%*","Reconstruction:" .. lang:getCanonicalName() .. "/")
link.fragment = ""
end
end
link.fragment = link.fragment and encode_entities(remove_formatting(link.fragment), "#%&+/:<=>@[\\]_{|}")


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