Module:linkeach: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:
local args = frame.args
local args = frame.args
local str = args[1]; local words = {}
local str = args[1]; local words = {}
local sep = args[2] or " "
for word in mw.ustring.gmatch(str, "(%S+)") do
for word in mw.ustring.gmatch(str, "(%S+)") do
word = "[[Contionary:" .. word .. "|" .. word .. "]]"
word = "[[Contionary:" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
table.insert(words, word)
end
return table.concat(words, sep)
end
 
function export.link_for_modules(str)
local words = {}
for word in mw.ustring.gmatch(str, "(%S+)") do
word = "[[" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
table.insert(words, word)
table.insert(words, word)
end
end
Line 13: Line 26:
return table.concat(words, " ")
return table.concat(words, " ")
end
end
function export.exist(frame)
local args = frame.args
local str = args[1]; local words = {}
local sep = args[2] or " "
for word in mw.ustring.gmatch(str, "(%S+)") do
if mw.title.new(word, 'Contionary').exists == true then
word = "[[Contionary:" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
table.insert(words, word)
else
table.insert(words, word)
end
end
return table.concat(words, sep)
end
return export
return export

Latest revision as of 15:55, 27 March 2021



local export = {}

function export.link(frame)
	
	local args = frame.args
	local str = args[1]; local words = {}
	local sep = args[2] or " "
	
	for word in mw.ustring.gmatch(str, "(%S+)") do
		word = "[[Contionary:" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
		table.insert(words, word)
	end
	
	return table.concat(words, sep)
end

function export.link_for_modules(str)
	
	local words = {}
	
	for word in mw.ustring.gmatch(str, "(%S+)") do
		word = "[[" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
		table.insert(words, word)
	end
	
	return table.concat(words, " ")
end

function export.exist(frame)

	local args = frame.args
	local str = args[1]; local words = {}
	local sep = args[2] or " "
	
	for word in mw.ustring.gmatch(str, "(%S+)") do
		if mw.title.new(word, 'Contionary').exists == true then
			word = "[[Contionary:" .. mw.ustring.lower(word) .. "|" .. word .. "]]"
			table.insert(words, word)
		else
			table.insert(words, word)
		end
	end
	
	return table.concat(words, sep)
end

return export