Module:ja-link/fast

Definition from Wiktionary, the free dictionary
Jump to navigation Jump to search
Text-x-generic with pencil.svg This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

-- Used in [[Wiktionary:Frequency lists/Japanese]]. Converts bare links to
-- {{l/ja}}-type links.
function export.link(frame)
	local text = frame.args[1]
	
	if not text then
		return nil
	end
	
	local function link(text)
		return '<span class="Jpan" lang="ja">[['
			.. text
			.. '#Japanese|' .. text .. ']]</span>'
	end
	
	return (text
		:gsub(
			"%[%[([^%]]+)%]%]",
			link))
end

return export