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

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


local function displayText(text, edition, fullName, largeInitial)
local function displayText(text, edition, fullName, largeInitial, nameAliases, keepElohim)
     if not fullName then
     if not fullName then
         if edition == 'כתיב' then
        for name, alias in pairs(nameAliases or {}) do
            text = text:gsub('אלהים', 'אלוקים')
            text = text:gsub(name, alias)
        else
        end
            text = text:gsub('אֱלֹה', 'אֱלֹק')
         if not keepElohim then
            if edition == 'כתיב' then
                text = text:gsub('אלהים', 'אלוקים')
            else
                text = text:gsub('אֱלֹה', 'אֱלֹק')
            end
         end
         end
     end
     end
שורה 29: שורה 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)
             return displayText(text, edition, frame.args[4] == 'מקור', record.largeInitial, data.nameAliases, record.keepElohim)
         end
         end
     end
     end
שורה 47: שורה 52:
     local edition = view == 'שורות' and 'ניקוד' or view
     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 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 = {
     local lines = {
         '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]',
         previous .. '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]',
         '',
         '',
     }
     }
שורה 65: שורה 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)
         local alias = displayText(text, edition, false, record.largeInitial, data.nameAliases, record.keepElohim)
         local source = displayText(text, edition, true, record.largeInitial)
         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 .. ']]'
שורה 79: שורה 85:
         else
         else
             verse = verse .. source
             verse = verse .. source
        end
        if view ~= 'שורות' and record.cantillationSection then
            verse = verse .. ' <small>[[' .. data.chapter .. '/טעמים#' ..
                record.cantillationSection .. '|שתי מערכות הטעמים]]</small>'
         end
         end
         lines[#lines + 1] = verse
         lines[#lines + 1] = verse

גרסה אחרונה מ־19:34, 1 בדצמבר 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
        if view ~= 'שורות' and record.cantillationSection then
            verse = verse .. ' <small>[[' .. data.chapter .. '/טעמים#' ..
                record.cantillationSection .. '|שתי מערכות הטעמים]]</small>'
        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