Module:head: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 33: Line 33:
if mw.ustring.match(head, "%*[^%*%[%]]*%[[^%*%]]+%][^%*]*%*") then
if mw.ustring.match(head, "%*[^%*%[%]]*%[[^%*%]]+%][^%*]*%*") then
for linker in mw.ustring.gmatch(head, "%*([^%*%[%]]*%[[^%*%[%]]+%][^%*]*)%*") do
for linker in mw.ustring.gmatch(head, "%*([^%*%[%]]*%[[^%*%[%]]+%][^%*]*)%*") do
local formatted = linker .. ":" .. mw.ustring.gsub(linker, "%[[^%*%[%]]+%]", "") -- turn word[s] into words:word
local with = mw.ustring.gsub(linker, "[%[%]]", "")
local escaped = mw.ustring.gsub(linker, "([%[%]%*])", "%$1")
local without = mw.ustring.gsub(linker, "%[[^%*%[%]]+%]", "")
head = mw.ustring.gsub(head, "%*" .. escaped .. "%*", "*" .. formatted .. "*")
local escaped = mw.ustring.gsub(linker, "([%[%]%*])", "%%%1")
mw.log(escaped)
head = mw.ustring.gsub(head, "%*" .. escaped .. "%*", "*" .. with .. ":" .. without .. "*")
end
end
end
end -- *word[s]* → *words:word*
head = mw.ustring.gsub(head, "%*([^%*:]+):([^%*:]+)%*", "[[%2#" .. data.language.name .. "|%1]]") -- *word:link*
head = mw.ustring.gsub(head, "%*([^%*:]+):([^%*:]+)%*", "[[%2#" .. data.language.name .. "|%1]]") -- *word:link*
head = mw.ustring.gsub(head, "%*([^%*]+)%*", "[[%1#" .. data.language.name .. "|%1]]") -- *word*
head = mw.ustring.gsub(head, "%*([^%*]+)%*", "[[%1#" .. data.language.name .. "|%1]]") -- *word*

Navigation menu