Module:See also: Difference between revisions

m
1 revision imported: Help:Footnotes
m (1 revision imported: Templates)
m (1 revision imported: Help:Footnotes)
 
(4 intermediate revisions by 2 users not shown)
Line 1:
--[[
-- This module produces a "See also: a, b, and c" link. It implements the
-- template {{see also}}.
--]]
 
local mHatnote = require('Module:Hatnote')
mTableToolslocal mHatlist = require('Module:TableToolsHatnote list')
local mTableTools -- lazily initialise
local mArguments -- lazily initialise
local libraryUtil = require('libraryUtil')
 
local checkType = libraryUtil.checkType
local p = {}
 
function p.seealsoseeAlso(frame)
mTableTools = require('Module:TableTools')
mArguments = require('Module:Arguments')
local args = mArguments.getArgs(frame, {parentOnly = true})
Line 17:
for k, v in pairs(args) do
if type(k) == 'number' then
local numstringdisplay = tostring(args['label ' .. k] or args['l' .. k)]
local displaypage = args['label ' ..display numstring]and
string.format('%s|%s', string.gsub(v, '|.*$', ''), display) or v
or args['l' .. numstring]
pages[k#pages + 1] = page
local page = {v, display}
pages[k] = page
end
end
pages = mTableTools.compressSparseArray(pages)
if not pages[1] then
return mHatnote.makeWikitextError(
Line 33 ⟶ 31:
end
local options = {
altphrase = args.altphrase,
selfref = args.selfref
}
return p._seealso_seeAlso(optionspages, unpack(pages)options)
end
 
function p._seealso_seeAlso(optionsargs, ...options)
checkType('_seeAlso', 1, args, 'table')
local altphrase = options and options.altphrase or 'See also'
checkType('_seeAlso', 2, options, 'table', true)
local links = mHatnote.formatPageTables(...)
options = options or {}
links = mw.text.listToText(links)
local textlist = altphrase .. ': ' .mHatlist.andList(args, linkstrue)
local text = string.format('See also: %s', list)
 
-- Pass options through.
local hnOptions = {}
hnOptions. selfref = options.selfref
}
 
return mHatnote._hatnote(text, hnOptions)
end