Module:BibleQuote

From BibleVerseWiki
Revision as of 16:15, 8 December 2023 by Kelvin (talk | contribs)

Documentation for this module may be created at Module:BibleQuote/doc

local p = {} --p stands for package

local function verses(frame)
    local _, _, book, chapter, startVerse, stopVerse = 
        string.find(frame.args[1], "%s-(.+)%s+(%d+):(%d+)-(%d+)")
    local verses = {}

    if stopVerse == nil then
        return frame:expandTemplate{title = frame.args[1]} 
    end
    
    for i = startVerse, stopVerse, 1 do
        local verse = frame:expandTemplate{title = book.." "..chapter..":"..i} 

        table.insert(verses, verse)        
    end

    return table.concat(verses, " ")
end

local function removePilcrow(verse)
    return string.gsub(verse, "¶ ", "")
end

function p.standard(frame)
    local result = verses(frame)

    if not frame.args.showPilcrow or frame.args.showPilcrow == nil then
        return removePilcrow(result)
    end

    return result
end

return p