Module:User:Erutuon/ja-link

Hello, you have come here looking for the meaning of the word Module:User:Erutuon/ja-link. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Erutuon/ja-link, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Erutuon/ja-link in singular and plural. Everything you need to know about the word Module:User:Erutuon/ja-link you have here. The definition of the word Module:User:Erutuon/ja-link will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Erutuon/ja-link, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

-- This is based on the function in ].
local function get_args(template_content)
	local args = {}
	local i = 0
	
	for arg in mw.text.gsplit(template_content, "¦", true) do
		local name, value = arg:match("^(.-)=(.-)$")
		if name then
			if value ~= "" then
				name = tonumber(name) or name
				args = value
			end
		elseif arg == "" then
			i = i + 1
			args = nil
		else
			i = i + 1
			args = arg
		end
	end
	
	return args
end

local script_data = mw.loadData "Module:scripts/data"
local kana = script_data.Kana.characters .. script_data.Hira.characters
local kana_pattern = "^+$"
local function is_kana(str)
	return mw.ustring.find(str, kana_pattern) ~= nil
end

local ja_link = require "Module:ja-link".link
local function process_ja_r_template(template_content)
	local args = get_args(template_content)
	
	-- This logic is copied from ].
	local kana = args
	if not kana then
		kana = args
		if not (kana and is_kana(kana)) then
			-- error
		end
	end
	
	local data = {
		lemma = args,
		kana = kana,
		gloss = args,
		lit = args,
		pos = args,
		linkto = args,
		transliteration = args,
	}
	
	local options = {
		caps = args,
		hist = args,
	}
	
	return ja_link(data, options)
end



function export.main(frame)
	local wikicode = frame:getParent().args
	
	if not wikicode then
		return ""
	else
		local result = (mw.ustring.gsub(wikicode, "⦃⦃ja%-r¦(+)⦄⦄", process_ja_r_template))
		return result
	end
end

return export