پودمان:Citation/Formatter
ظاهر
توضیحات این پودمان میتواند در پودمان:Citation/Formatter/توضیحات قرار گیرد.
--------------------------------------------------------------------------------
-- Module:Citation (Formatter Layer)
-- تبدیل داده خام به خروجی قابل نمایش
--------------------------------------------------------------------------------
local U = require("Module:Citation/Utilities")
local cfg = require("Module:Citation/Configuration")
local F = {}
--------------------------------------------------------------------------------
-- ساخت لینک
--------------------------------------------------------------------------------
function F.formatUrl(url)
if U.isEmpty(url) then
return ""
end
url = U.makeUrl(url)
return "[" .. url .. " " .. url .. "]"
end
--------------------------------------------------------------------------------
-- italic کردن عنوان
--------------------------------------------------------------------------------
function F.formatTitle(title)
if U.isEmpty(title) then
return ""
end
return "''" .. title .. "''"
end
--------------------------------------------------------------------------------
-- نویسنده ساده (فعلاً بدون parsing پیچیده)
--------------------------------------------------------------------------------
function F.formatAuthor(author)
if U.isEmpty(author) then
return ""
end
return author
end
--------------------------------------------------------------------------------
-- تاریخ ساده (بدون تبدیل تقویم)
--------------------------------------------------------------------------------
function F.formatDate(date)
if U.isEmpty(date) then
return ""
end
return date
end
--------------------------------------------------------------------------------
-- بایگانی
--------------------------------------------------------------------------------
function F.formatArchive(url, date)
if U.isEmpty(url) then
return ""
end
local parts = {}
table.insert(parts, "بایگانی:")
table.insert(parts, F.formatUrl(url))
if not U.isEmpty(date) then
table.insert(parts, "(" .. date .. ")")
end
return table.concat(parts, " ")
end
--------------------------------------------------------------------------------
-- ساخت یک بخش استاندارد
--------------------------------------------------------------------------------
function F.renderField(label, value)
if U.isEmpty(value) then
return ""
end
return value
end
--------------------------------------------------------------------------------
-- اتصال Formatter به Core (override ساده)
--------------------------------------------------------------------------------
function F.apply(coreModule)
-- این بخش بعداً در Citation استفاده میشود
coreModule.format = F
return coreModule
end
--------------------------------------------------------------------------------
return F