יחידה:הערה

ווערסיע פון 21:32, 7 סעפטעמבער 2025 דורך תנא קמא (שמועס | ביישטייערונגען) (עבר הזמן)
(חילוק) → עלטערע ווערסיע | איצטיגע ווערסיע (חילוק) | נייערע ווערסיע ← (חילוק)

מען קען שאפן דאקומענטאציע פאר דעם מאדול ביי יחידה:הערה/דאק

local Ref = {}


local function hasHebrew(text)
	return mw.ustring.find(text, "[א-ת]")
end

function parseRef(frame)
	local argModule = require('Module:Arguments')
	local warnings=''
	local text=''
	local refDic = {}
	local args = argModule.getArgs(frame)
	local refName = args['שם'] or args['name'] or args['נאמען']
	local ibid = args['דארט']
	local refGroup = args['קבוצה'] or args['group']
	local direction = args['כיוון']
	
	
	if direction and direction ~= 'ימין' and direction ~= 'שמאל' then
		warnings = '<span class="error">פרמטר כיוון שגוי</span>[[קאטעגאריע:דפים עם שגיאות בהערה]]'
	end
	if args[2] then
		warnings = '<span class="error"><sup> פרמטר שני בהערה: </sup></span>[[קאטעגאריע:דפים עם שגיאות בהערה]]'
	end
	
	text = args[1]
	
	if text then
		text = frame:preprocess(args[1])
		if not text == nil then text = trim(trim) end
	    if text:match("%.%.$") then
	         text =text:sub(1, -2)
	    end
	    if not text:match("[!\"'()%,%-.:;?`]$") then
	         text = text .. "."
	    end
    end
	if refName and #refName then refDic['name'] = refName end
	if ibid and #ibid then refDic['extends'] = ibid end
	if refGroup and #refGroup then refDic['group'] = refGroup end
	
	if direction and direction=='שמאל' then refDic['dir'] = 'ltr' end
	if direction and direction=='ימין' then refDic['dir'] = 'rtl' end
	if text and not hasHebrew(text) then
		refDic['dir'] = 'ltr'
	end

	if text and #text>0 then
		return frame:extensionTag{ name = 'ref', content=text, args = refDic } .. warnings
	else
		return frame:extensionTag{ name = 'ref', args = refDic } .. warnings
	end
end

Ref['הערה'] = parseRef
Ref['parseRef'] = parseRef
return Ref