Module:Numlinks

From Xenharmonic Wiki
Revision as of 19:39, 6 December 2024 by Ganaram inukshuk (talk | contribs) (simplify args)
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]
This module implements a metatemplate, and may be invoked by templates using its corresponding template Template:Numlinks, or used directly from other modules.

This module generates previous and next links for a numbered page.


Introspection summary for Module:Numlinks 
Functions provided (1)
Line Function Params
27 _numlinks (main) (args)
Lua modules required (1)
Variable Module Functions used
ordinal Module:Ordinal dependency not used

No function descriptions were provided. The Lua code may have further information.


-- Page is following provisonal style guide: User:Ganaram_inukshuk/Provisional_style_guide_for_Lua

local ordinal = require("Module:Ordinal")._ordinal

-- Generate a table of previous and next links for numbered pages, with support
-- for up to two numbers. Args are as follows:
-- - Link config: what is the arrangement of links? Options are:
-- -- Side-1: For n, links are for n-1 and n+1
-- -- Side-2: For n, links are for n-2 to n+1
-- -- Side-3: For n, links are for n-3 to n+3
-- -- Side-4: For n, links are for n-4 to n+4
-- -- Side-5: For n, links are for n-5 to n+5
-- -- 8-Link: For n and m, links are n +/- 1 and m +/- 1. There are no options
--    for additional links.
-- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal
--   numbers (eg, 12th-octave)?
-- - Page text: Text is formatted as [pre-text][n][post-text], stored in a table
--   { pre } or { pre, post }. If the link config is for 8 links, then text is
--   formatted as [pre-text][n][mid-text][m][post-text], stored in a table
--   { mid, post } or { pre, mid, post }. Pre-text can be omitted since most
--   pages don't have pre-text (12edo, 5L 2s). 
-- - Link text: Same as page text, except this changes the text of the link. If
--   this is not specified, then the page and link text are the same.
-- - Min: The smallest allowed value for a numbered link. Default is 1. There
--   isn't a maximum since these numbers are assumed to be either natural or
--   whole numbers.
function p._numlinks(args)
	local link_config = args["Link Config"]
	local is_ordinal  = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false
	local page_text   = args["Page Text"]
	local link_text   = args["Link Text"] ~= nil and args["Link Text"] or args["Page Text"]
	local min_1       = args["Min 1"] ~= nil and args["Min 1"] or 1
	local min_2       = args["Min 2"] ~= nil and args["Min 2"] or 1
	
end