Module:R:Slater

local export = {}

local collisions = require("Module:R:Slater/collision-data")

function is_collision(x) if collisions[mw.ustring.lower(x)] == nil then return false else return true end end

function format_perseus_url(title, beta, redirect) local url_redirect_lhs = 'http://www.perseus.tufts.edu/hopper/resolveform?type=exact&lookup=' local url_entry_lhs = 'http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0072:entry=' local url_rhs = redirect and '&lang=greek' or '' return (redirect and url_redirect_lhs or url_entry_lhs)..beta..url_rhs end

function format_perseus_wikilink(title, beta, redirect) local url = format_perseus_url(title, beta, redirect) local w_link = '«['..url..' '..title..']» in ' return (beta ==  and  or w_link) end

function export.create(frame) local args = frame:getParent.args local title = args['w'] or mw.title.getCurrentTitle.text local beta = args[1] or require("Module:grc-polytonic-to-perseus-betacode").polytonic_to_perseus_betacode(title) --polytonic_to_perseus_beta(title) local redirect = is_collision(title) and not args[1] and not args['w'] return format_perseus_wikilink(title, beta, redirect) end

return export