Module:Bibleverse

local p = {}

function p.main( frame ) local pframe    = frame:getParent local args        = pframe.args local urlpat    = "http://bible.oremus.org/passage=%book+%s_chap:%s_vers&version=%version" local book       = args[1] local ref       = args[2] local defver   = "nrsv" local text       = args[4] colon = mw.ustring.match( ref, ":" ) reflen = mw.ustring.len( ref ) s_chap = mw.ustring.sub( ref, 1, colon ) s_vers = mw.ustring.sub( ref, colon + 1, reflen - colon )

version = args [3] or defver url_w_bk = mw.ustring.gmatch( urlpat, "%book", book ) url_w_s_chap = mw.ustring.gmatch( url_w_bk, "%s_chap", s_chap ) url_w_s_vers = mw.ustring.gmatch( url_w_s_chap, "%s_vers", s_vers ) url_w_version = mw.ustring.gmatch( url_w_s_vers, "%s_chap", version ) url = url_w_version fulllink = "[" .. url .. " " .. text .. "]"   return fulllink end

return p