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

מתוך חב"דטקסט, מאגר טקסטים חב"דים חופשיים
קפיצה לניווט קפיצה לחיפוש
(קישור נקודתי לשתי מערכות הטעמים בבראשית לה, כב)
(אפשרות להצגת נוסח הפרק בלי ניווט פנימי)
שורה 52: שורה 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 = {
    if frame.args['ניווט'] ~= 'לא' then
        previous .. '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]',
        local previous = data.previousChapter and '[[' .. data.previousChapter .. '|הפרק הקודם]] • ' or ''
         '',
        lines[#lines + 1] = previous .. '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]'
    }
         lines[#lines + 1] = ''


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



גרסה מ־01:36, 2 בדצמבר 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 lines = {}
    if frame.args['ניווט'] ~= 'לא' then
        local previous = data.previousChapter and '[[' .. data.previousChapter .. '|הפרק הקודם]] • ' or ''
        lines[#lines + 1] = previous .. '[[' .. data.book .. '|ספר ' .. data.book .. ']] • פרק ' .. data.number .. ' • [[' .. data.nextChapter .. '|הפרק הבא]]'
        lines[#lines + 1] = ''

        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] = ''
    end
    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