Module:Numlinks

From Xenharmonic Wiki
Revision as of 08:24, 6 December 2024 by Ganaram inukshuk (talk | contribs) (Created page with "-- Page is following provisonal style guide: User:Ganaram_inukshuk/Provisional_style_guide_for_Lua local ordinal = require("Module:Ordinal")._ordinal -- Generate a table of...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
22 _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 count: how many links up and down should be displayed? For n, a count
--   of 1 gives links for n-1 and n+1; count 2 is n-2, n-1, n+1, and n+2. This
--   does not apply if there are two values n and m, to limit the number of
--   links to be made.
-- - 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 two values, n and m, are present, then the
--   format is [pre-text-1][n][post-text-1][pre-text-2][m][post-text-2], where
--   the second pre/post text is entered as a second table.
-- - 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_count  = args["Link Count"]
	local is_ordinal  = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false
	local page_text_1 = args["Page Text 1"]
	local page_text_2 = args["Page Text 2"]
	local link_text_1 = args["Link Text 1"] ~= nil and args["Link Text 1"] or args["Page Text 1"]
	local link_text_2 = args["Link Text 2"] ~= nil and args["Link Text 2"] or args["Page Text 2"]
	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