Module:labels: Difference between revisions

m
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
mNo edit summary
mNo edit summary
Line 27: Line 27:
local cats = ""
local cats = ""
local skip_comma = false
local skip_comma = false
local conjunctions = {["and"] = true, ["or"] = true, ["/"] = true}
local it = 1
local it = 1
Line 44: Line 46:
table.insert(labels, it + 1, after)
table.insert(labels, it + 1, after)
table.insert(labels, it + 1, "/")
table.insert(labels, it + 1, "/")
end
for conjunction, _ in pairs(conjunctions) do
if mw.ustring.find(labels[it], "^.+%s+" .. conjunction .. "%s+.+") then
local before = mw.ustring.gsub(labels[it], "^(.+)%s+conjunction%s+(.+)", "%1")
local conj_temp = mw.ustring.gsub(labels[it], "^(.+)%s+conjunction%s+(.+)", "%2")
local after = mw.ustring.gsub(labels[it], "^(.+)%s+conjunction%s+(.+)", "%3")
labels[it] = before
table.insert(labels, it + 1, after)
table.insert(labels, it + 1, conj_temp)
end
end
end
it = it + 1
it = it + 1
Line 61: Line 73:
local label = l_data.labels[l_id]
local label = l_data.labels[l_id]
if i > 1 then
if i > 1 then
local conjunctions = {["with"] = true, ["and"] = true, ["or"] = true, ["/"] = true}
if conjunctions[l_id] or conjunctions[labels[i-1]] or mw.ustring.find(l_id, "^with%s") then
if conjunctions[l_id] or conjunctions[labels[i-1]] or mw.ustring.find(l_id, "^with%s") then
skip_comma = true
skip_comma = true