Kontent qismiga oʻtish

Modul:ko-link

Vikilug‘atdan olingan

Bu modul uchun Modul:ko-link/doc nomli hujjat sahifasini yaratishingiz mumkin

local export = {}

-- Language-tags any bare links. Used in [[Wiktionary:Frequency lists/Korean 5800]].
function export.link(frame)
	local text = frame.args[1]
	
	if not text then
		return nil
	end
	
	local function link(text)
		return '<span class="Kore" lang="ko">[['
			.. text
			.. '#Korean|' .. text .. ']]</span>'
	end
	
	local function tag(text)
		return '<span class="Kore" lang="ko">' .. text .. '</span>'
	end
	
	return (text
		:gsub(
			"%[%[([^%]]+)%]%]",
			link)
		:gsub( -- Korean words inside parentheses
			"%(([^)]+)%)",
			function (text)
				return "(" .. tag(text) .. ")"
			end))
end

return export