יחידה:פרשן שולחן ערוך
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:פרשן שולחן ערוך/תיעוד
-- Alias for commenters.
-- We want to use the same name, discard the alias that is used.
local commenterAlias = {}
-- assigning the shortcuts for the commenters.
-- line is split for readability.
commenterAlias["מב"] =
"מב"
commenterAlias["משנה ברורה"] =
"מב"
commenterAlias["פת"] =
"פת"
commenterAlias["פתחי תשובה"] =
"פת"
commenterAlias["בהט"] =
"בהט"
commenterAlias["באר היטב"] =
"בהט"
commenterAlias["מא"] =
"מא"
commenterAlias["מגא"] =
"מא"
commenterAlias["מגן אברהם"] =
"מא"
commenterAlias["שך"] =
"שך"
commenterAlias["שפתי כהן"] =
"שך"
commenterAlias["קצות"] =
"קצות"
commenterAlias["קצות החושן"] =
"קצות"
commenterAlias["נתב"] =
"נתב"
commenterAlias["נתיבות (ביאורים)"] =
"נתב"
commenterAlias["נתיבות המשפט (ביאורים)"] =
"נתב"
commenterAlias["בש"] =
"בש"
commenterAlias["בית שמואל"] =
"בש"
commenterAlias["בהל"] =
"בהל"
commenterAlias["ביאור הלכה"] =
"בהל"
commenterAlias["טז"] =
"טז"
commenterAlias["טורי זהב"] =
"טז"
commenterAlias["חמ"] =
"חמ"
commenterAlias["חלקת מחוקק"] =
"חמ"
commenterAlias["סמע"] =
"סמע"
commenterAlias["ספר מאירת עיניים"] =
"סמע"
commenterAlias["כהח"] =
"כהח"
commenterAlias["כף החיים"] =
"כהח"
commenterAlias["בהג"] =
"בהג"
commenterAlias["באר הגולה"] =
"בהג"
commenterAlias["שעת"] =
"שעת"
commenterAlias["עת"] =
"עת"
commenterAlias["בגר"] =
"בגר"
commenterAlias["פרמג"] =
"פרמג"
commenterAlias["פרח"] =
"פרח"
commenterAlias["פרי חדש"] =
"פרח"
local colours = {}
-- assigning the colours.
-- line is split for readability.
colours["מב"] =
"תכלת"
colours["פתחי תשובה"] =
"תכלת"
colours["פת"] =
"תכלת"
colours["בהט"] =
"זהב כהה"
colours["מגא"] =
"חום"
colours["מא"] =
"חום"
colours["שך"] =
"חום"
colours["בש"] =
"חום"
colours["בהל"] =
"טורקיז"
colours["טז"] =
"ירוק"
colours["חמ"] =
"מג'נטה"
colours["סמע"] =
"מג'נטה"
colours["כהח"] =
"סגול"
colours["בהג"] =
"שזיף"
colours["בגר"]=
"שחור"
colours["פרמג"]=
"שחור"
colours["פרח"]=
"ורוד"
--end of colour assignments
--shortcut names assignments
local BooksShortcuts = {}
BooksShortcuts["חומ"] =
"שולחן ערוך חושן משפט"
BooksShortcuts["אהע"] =
"שולחן ערוך אבן העזר"
BooksShortcuts["אוח"] =
"שולחן ערוך אורח חיים"
BooksShortcuts["יוד"] =
"שולחן ערוך יורה דעה"
BooksShortcuts["משנב"] =
"משנה ברורה על אורח חיים"
--end of shortcuts assignments
local p = {}
local function commentIdModifier(commentID, commenter)
if commenter == "בהל" then
commentID = "*"
end
return commentID
end
local function viewComments(title)
if mw.ustring.match(title, '%a+ %a+ %a+ %a+ %a%a?%a?%a? %a%a?%a?') then
return true
else
return nil
end
end
--frame[1] = name of commenter
--frame[2] = the comment ID
--frame[3] = the short book name
--frame[4] = the section
local function commenterRef(frame)
local book = frame.args[3] or "חומ"
local section = frame.args[4] or "פז"
assert(section, "section is nil")
--local iPName = BooksShortcuts[book].. " ".. section -- the page on which the comment reference won't be shown.
local commenter = commenterAlias[frame.args[1]] or "סמע"
local commentID = frame.args[2] or "א"
--if iPName == mw.title.getCurrentTitle().text then return nil
if not viewComments(mw.title.getCurrentTitle().text) then return nil
else
local modifiedText = commentIdModifier(commentID, commenter)
ret = mw.html.create('span')
:attr('id', commentID..'_'..commenter)
ret:tag('sup'):wikitext("[[#"..commenter.." "..commentID.."|"..frame:expandTemplate{
title = "צבע גופן",
args = {colours[commenter],
modifiedText
}
}.."]]"
)
return ret
end
end
local function commenterStart(frame)
local commentID = frame.args[2]
local commenterName = commenterAlias[frame.args[1]]
local text = frame.args[3]
local mCommentId = commentIdModifier(commentID, commenterName)
return tostring(mw.html.create('span')
:attr('id', commenterName..'_'..commentID))
.."'''"
.."[[#"
..commentID..'_'..commenterName
..'|'..'('..mCommentId..')'..']] '
..text
.."'''"
end
return {
commenterRef = commenterRef,
['פרשע'] = commenterRef,
commenterStart = commenterStart,
['משע'] = commenterStart
}