Module:User:Benwing2/references

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


local export = {}

local rsplit = mw.text.split

-- Parse a references spec as used in the |ref= param to {{IPA}} and {{IPAchar}} and soon the |fNref= param to {{head}}.
-- Multiple references are separated by !!! (optionally with spaces around it), and the equivalent of
-- <ref name="bendo">{{R:it:DiPI|bendo}}</ref><ref>{{R:it:Olivetti}}</ref> can be specified using a syntax like the following:
-- {{IPA|it|ˈben.do|ˈbɛn.do|ref2={{R:it:DiPI|bendo}}<<name:bendo>> !!! {{R:it:Olivetti}}}}
-- To include a group as in,<ref name="bendo" group="pron">...</ref> use:
-- {{IPA|it|ˈben.do|ˈbɛn.do|ref2={{R:it:DiPI|bendo}}<<name:bendo>><<group:pron>>}}
-- To reference a prior name, as in <ref name="bendo"/>, leave the reference text blank:
-- {{IPA|it|ˈben.do|ˈbɛn.do|ref2=<<name:bendo>>}}
-- Similarly, to reference a prior name in a particular group, as in <ref name="bendo" group="pron"/>, use:
-- {{IPA|it|ˈben.do|ˈbɛn.do|ref2=<<name:bendo>><<group:pron>>}}
function export.parse_references(text)
	local refs = {}
	local raw_notes = rsplit(text, "%s*!!!%s*")
	for _, raw_note in ipairs(raw_notes) do
		local note
		if raw_note:find("<<") then
			local splitvals = require("Module:string utilities").capturing_split(raw_note, "(<<+:.->>)")
			note = {text = splitvals}
			for i = 2, #splitvals, 2 do
				local key, value = splitvals:match("^<<(+):(.*)>>$")
				if not key then
					error("Internal error: Can't parse " .. splitvals)
				end
				if key == "name" or key == "group" then
					note = value
				else
					error("Unrecognized key '" .. key .. "' in " .. splitvals)
				end
				if splitvals ~= "" then
					error("Extraneous text '" .. splitvals .. "' after " .. splitvals)
				end
			end
		else
			note = raw_note
		end
		table.insert(refs, note)
	end
	
	return refs
end

return export