יחידה:מקרא: הבדלים בין גרסאות בדף

מתוך חב"דטקסט, מאגר טקסטים חב"דים חופשיים
קפיצה לניווט קפיצה לחיפוש
(תמיכה בכינויי שמות הקודש לפי נתוני הפרק ובקישור לפרק הקודם)
(תצוגת המקרא: שמירה על ״בני האלהים״ בבראשית ו, ב וד)
שורה 5: שורה 5:
end
end


local function displayText(text, edition, fullName, largeInitial, nameAliases)
local function displayText(text, edition, fullName, largeInitial, nameAliases, keepElohim)
     if not fullName then
     if not fullName then
         for name, alias in pairs(nameAliases or {}) do
         for name, alias in pairs(nameAliases or {}) do
             text = text:gsub(name, alias)
             text = text:gsub(name, alias)
         end
         end
         if edition == 'כתיב' then
         if not keepElohim then
            text = text:gsub('אלהים', 'אלוקים')
            if edition == 'כתיב' then
        else
                text = text:gsub('אלהים', 'אלוקים')
            text = text:gsub('אֱלֹה', 'אֱלֹק')
            else
                text = text:gsub('אֱלֹה', 'אֱלֹק')
            end
         end
         end
     end
     end
שורה 32: שורה 34:
         if record.number == verseNumber then
         if record.number == verseNumber then
             local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
             local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
             return displayText(text, edition, frame.args[4] == 'מקור', record.largeInitial, data.nameAliases)
             return displayText(text, edition, frame.args[4] == 'מקור', record.largeInitial, data.nameAliases, record.keepElohim)
         end
         end
     end
     end
שורה 69: שורה 71:
         local number = record.number
         local number = record.number
         local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
         local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
         local alias = displayText(text, edition, false, record.largeInitial, data.nameAliases)
         local alias = displayText(text, edition, false, record.largeInitial, data.nameAliases, record.keepElohim)
         local source = displayText(text, edition, true, record.largeInitial, data.nameAliases)
         local source = displayText(text, edition, true, record.largeInitial, data.nameAliases, record.keepElohim)
         local label = data.number .. '_' .. number
         local label = data.number .. '_' .. number
         local target = '[[:קטגוריה:' .. data.chapter .. ' ' .. number .. '|' .. number .. ']]'
         local target = '[[:קטגוריה:' .. data.chapter .. ' ' .. number .. '|' .. number .. ']]'

גרסה מ־16:49, 30 בנובמבר 2026

ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:מקרא/תיעוד

local p = {}

local function chapterData(frame)
    return mw.loadData('Module:מקרא/' .. frame.args[1])
end

local function displayText(text, edition, fullName, largeInitial, nameAliases, keepElohim)
    if not fullName then
        for name, alias in pairs(nameAliases or {}) do
            text = text:gsub(name, alias)
        end
        if not keepElohim then
            if edition == 'כתיב' then
                text = text:gsub('אלהים', 'אלוקים')
            else
                text = text:gsub('אֱלֹה', 'אֱלֹק')
            end
        end
    end

    if largeInitial then
        local first = edition == 'כתיב' and 'ב' or 'בְּ'
        if text:sub(1, #first) == first then
            text = '<big>' .. first .. '</big>' .. text:sub(#first + 1)
        end
    end
    return text
end

function p.verse(frame)
    local data = chapterData(frame)
    local verseNumber, edition = frame.args[2], frame.args[3]
    for _, record in ipairs(data.verses) do
        if record.number == verseNumber then
            local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
            return displayText(text, edition, frame.args[4] == 'מקור', record.largeInitial, data.nameAliases, record.keepElohim)
        end
    end
    error('פסוק לא נמצא בפרק')
end

local headings = {
    {'כתיב', 'כתיב (אותיות בלבד)'},
    {'ניקוד', 'מנוקד'},
    {'שורות', 'מנוקד בשורות'},
    {'טעמים', 'עם טעמי המקרא'},
}

function p.chapter(frame)
    local data = chapterData(frame)
    local view = frame.args[2]
    local edition = view == 'שורות' and 'ניקוד' or view
    local style = [[font-family: SBL Hebrew, Ezra SIL, Noto Serif Hebrew, serif; font-size:1.35em; line-height:1.8]]
    local previous = data.previousChapter and '[[' .. data.previousChapter .. '|הפרק הקודם]] • ' or ''
    local lines = {
        previous .. '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]',
        '',
    }

    local navigation = {}
    for _, item in ipairs(headings) do
        local destination, label = unpack(item)
        navigation[#navigation + 1] = destination == view and label or
            '[[' .. data.chapter .. '/' .. destination .. '|' .. label .. ']]'
    end
    lines[#lines + 1] = table.concat(navigation, ' • ')
    lines[#lines + 1] = ''
    lines[#lines + 1] = '<div class="ct-mikra-editions" lang="hbo" style="' .. style .. '">'

    for index, record in ipairs(data.verses) do
        local number = record.number
        local text = assert(record[edition], 'מהדורת מקרא לא מוכרת')
        local alias = displayText(text, edition, false, record.largeInitial, data.nameAliases, record.keepElohim)
        local source = displayText(text, edition, true, record.largeInitial, data.nameAliases, record.keepElohim)
        local label = data.number .. '_' .. number
        local target = '[[:קטגוריה:' .. data.chapter .. ' ' .. number .. '|' .. number .. ']]'
        local verse = '<span id="' .. label .. '"></span><span id="' .. number .. '"></span>'
        if edition == 'טעמים' and record.aliyah then
            verse = verse .. '<small>[' .. record.aliyah .. ']</small> '
        end
        verse = verse .. '<small>' .. target .. '</small> '
        if alias ~= source then
            verse = verse .. '<span class="ct-mikra-alias">' .. alias ..
                '</span><span class="ct-mikra-source" style="display:none">' .. source .. '</span>'
        else
            verse = verse .. source
        end
        lines[#lines + 1] = verse
        if data.verses[index + 1] ~= nil and (view == 'שורות' or record.paragraphEnd) then
            lines[#lines + 1] = ''
        end
    end
    lines[#lines + 1] = '</div>'
    return table.concat(lines, '\n')
end

return p