Module:Numlinks: Difference between revisions
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..." |
simplify args |
||
| Line 5: | Line 5: | ||
-- Generate a table of previous and next links for numbered pages, with support | -- Generate a table of previous and next links for numbered pages, with support | ||
-- for up to two numbers. Args are as follows: | -- for up to two numbers. Args are as follows: | ||
-- - Link | -- - 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 | -- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal | ||
-- numbers (eg, 12th-octave)? | -- numbers (eg, 12th-octave)? | ||
-- - Page text: Text is formatted as [pre-text][n][post-text], stored in a table | -- - Page text: Text is formatted as [pre-text][n][post-text], stored in a table | ||
-- { pre } or { pre, post }. If | -- { 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 | -- - 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. | -- this is not specified, then the page and link text are the same. | ||
| Line 21: | Line 26: | ||
-- whole numbers. | -- whole numbers. | ||
function p._numlinks(args) | function p._numlinks(args) | ||
local | local link_config = args["Link Config"] | ||
local is_ordinal = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false | local is_ordinal = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false | ||
local | local page_text = args["Page Text"] | ||
local | 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_1 = args["Min 1"] ~= nil and args["Min 1"] or 1 | ||
local min_2 = args["Min 2"] ~= nil and args["Min 2"] or 1 | local min_2 = args["Min 2"] ~= nil and args["Min 2"] or 1 | ||
end | end | ||