Dokumentaciju za ovaj modul možete napraviti na stranici Modul:Wikidata/cite/dok

require "Modul:No globals"

local p = {}

local lib = require 'Modul:Wikidata/lib'

local props = {
	P248 = {},
	P627 = {
		pattern = '[http://www.iucnredlist.org/details/$1/0 Dostupno na internetu]',
	},
	P813 = {
		linked = false
	},
	P854 = {
		pattern = '[$1 Dostupno na internetu]',
	},
}

function p.formatSource(references, options)
	local frame = mw.getCurrentFrame()
	local Formatters = require 'Modul:Wikidata/Formatters'
	local valid_refs = {}
	local limit = tonumber(options.max_ref)
	for _, ref in pairs(references) do
		if limit and #valid_refs == limit then
			break
		end
		local Values = {}
		for prop, opt in pairs(props) do
			if ref.snaks[prop] then
				local Snaks = {}
				for _, snak in pairs(ref.snaks[prop]) do
					if lib.IsSnakValue(snak) then
						table.insert(Snaks, Formatters.getFormattedValue(snak, opt)) -- TODO
					end
				end
				if #Snaks > 0 then
					table.insert(Values, mw.text.listToText(Snaks))
				end
			end
		end
		if #Values > 0 then
			table.insert(valid_refs, frame:extensionTag('ref', table.concat(Values, '. ') .. '.', { name = ref.hash }))
		end
	end
	return table.concat(valid_refs)
end

return p