Module:Numlinks: Difference between revisions

Ganaram inukshuk (talk | contribs)
m todo
ArrowHead294 (talk | contribs)
m Wikitext debugger option
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
-- Page is following provisonal style guide: User:Ganaram_inukshuk/Provisional_style_guide_for_Lua
-- This module follows [[User:Ganaram inukshuk/Provisional style guide for Lua]]
local getArgs = require("Module:Arguments").getArgs
local getArgs = require("Module:Arguments").getArgs
local ordinal = require("Module:Ordinal"  )._ordinal
local ordinal = require("Module:Ordinal"  )._ordinal
Line 80: Line 80:
-- arrow before the first link.
-- arrow before the first link.
local prev_links = {}
local prev_links = {}
if curr_num - num_links >= min_num then
if curr_num - num_links > min_num then
table.insert(prev_links, "←")
table.insert(prev_links, "←")
end
end
Line 135: Line 135:
end
end
end
end
-- wip; to be placed in its own module
--[[
function p.numlinks_2num(args)
local curr_num_1  = args["Num 1"]
local min_num_1    = args["Min 1"] or 1
local curr_num_2  = args["Num 2"]
local min_num_2    = args["Min 2"] or 1
local disp_text    = args["Page Text"] or { "PRE-TEXT", "MID-TEXT", "POST-TEXT" }
local link_text    = args["Link Text"] or nil
local is_ordinal_1 = args["Is Ordinal 1"] ~= nil and args["Is Ordinal 1"] or false
local is_ordinal_2 = args["Is Ordinal 1"] ~= nil and args["Is Ordinal 2"] or false
local x = curr_num_1
local y = curr_num_2
local link_nums = {
{x-1, y-1}, {x  , y-1}, {x+1, y-1},
{x-1, y  },            {x+1, y  },
{x-1, y+1}, {x  , y+1}, {x+1, y+1}
}
local links = {}
for i = 1, #link_nums do
end
end
]]--


-- Main function
-- Main function
function p.numlinks(frame)
function p.numlinks(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local wtext = yesno(frame.args["wtext"] or args["wtext"])
-- Preprocess numeric input
-- Preprocess numeric input
Line 178: Line 152:
-- Create numbered navigation links
-- Create numbered navigation links
local result = p._numlinks(args)
local result = p._numlinks(args)
-- Debugger option to show Wikitext
if wtext then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end


return result
return frame:preprocess(result)
end
end