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

จาก วิกิพจนานุกรม พจนานุกรมเสรี
เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
ZilentFyld (คุย | ส่วนร่วม)
// Edit via Wikiplus
ZilentFyld (คุย | ส่วนร่วม)
// Edit via Wikiplus
บรรทัดที่ 15: บรรทัดที่ 15:
for item in mw.text.gsplit(template, "\n") do
for item in mw.text.gsplit(template, "\n") do
--table.insert(set, sub(item,6,-3) ~= title and sub(item,6,-3) or nil)
--table.insert(set, sub(item,6,-3) ~= title and sub(item,6,-3) or nil)
table.insert(set, match(item,'{{ws|(.+)}}') ~= title and sub(item,6,-3) or nil)
table.insert(set, match(item,'{{ws|(.+)}}') ~= title and match(item,'{{ws|(.+)}}') or nil)
end
end
--set["name"] = ((args["name"] or kind) == "ant") and "คำตรงข้ามของ" or "คำพ้องความของ"
--set["name"] = ((args["name"] or kind) == "ant") and "คำตรงข้ามของ" or "คำพ้องความของ"

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

local M = {}

local match = mw.ustring.match
local sub = mw.ustring.sub

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 "คำพ้องความ"
	local template = match(content, "=+ *".. temp .." *=+\n{{ws beginlist}}(.+){{ws endlist}}")
	if template and template ~= "" then
		local set = {}
		for item in mw.text.gsplit(template, "\n") do
			--table.insert(set, sub(item,6,-3) ~= title and sub(item,6,-3) or nil)
			table.insert(set, match(item,'{{ws|(.+)}}') ~= title and match(item,'{{ws|(.+)}}') 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 --"''ดูที่ [[อรรถาภิธาน:" .. title .. "]]''" .. 
		'<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[[อรรถาภิธาน:' .. title .. '|หน้า]]</span> <span class="plainlinks">[' ..
		tostring(mw.uri.fullUrl("อรรถาภิธาน:" .. word, { ["action"] = "edit" })) ..
		' edit]</span></div>' .. frame:expandTemplate{ title = "template:th-saurus-list", args = set }
	else
		return ""
	end
end

return M