ผลต่างระหว่างรุ่นของ "มอดูล:th-saurus"

จาก วิกิพจนานุกรม พจนานุกรมเสรี
เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
ZilentFyld (คุย | ส่วนร่วม)
// Edit via Wikiplus
ZilentFyld (คุย | ส่วนร่วม)
// Edit via Wikiplus
บรรทัดที่ 12: บรรทัดที่ 12:
if template and template ~= "" then
if template and template ~= "" then
local set = {}
local set = {}
for item in mw.text.gsplit(template, "") do
for item in mw.text.gsplit(template, "\n") do
table.insert(set, item ~= title and item or nil)
table.insert(set, item ~= title and item or nil)
end
end

รุ่นแก้ไขเมื่อ 22:47, 20 พฤศจิกายน 2563

local M = {}

local match = mw.ustring.match

function M.syn(frame, kind)
	local args = frame:getParent().args
	local title = mw.title.getCurrentTitle().text
	local word = args[1] or title
	local content = mw.title.new("อรรถาภิธาน:" .. word):getContent()
	local temp = kind or "syn"
	local template = match(content, "{{ws beginlist}}(.+){{ws endlist}}")
	if template and template ~= "" then
		local set = {}
		for item in mw.text.gsplit(template, "\n") do
			table.insert(set, item ~= title and item or nil)
		end
		--set["name"] = ((args["name"] or kind) == "ant") and "คำตรงข้ามของ" or "คำพ้องความของ"
		set["title"] = args["title"] or nil
		--if args["fold"] or #set > 10 then set["fold"] = 1 end
		return '<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[' ..
		tostring(mw.uri.fullUrl("อรรถาภิธาน:" .. word, { ["action"] = "edit" })) ..
		' edit]</span></div>' .. frame:expandTemplate{ title = "template:th-syn-list", args = set }
	else
		return ""
	end
end

return M