"మాడ్యూల్:Hatnote list" కూర్పుల మధ్య తేడాలు

Updated from sandbox
చి (Actually applied andList's formatted option in forSeeTableToString)
(Updated from sandbox)
-- Set the separator; if any item contains it, use the alternate separator
local separator = options.separator
--searches display text only
function searchDisp(t, f)
return string.find(string.sub(t, (string.find(t, '|') or 0) + 1), f)
end
for k, v in pairs(list) do
if string.findsearchDisp(v, separator) then
separator = options.altSeparator
break
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§"
local conjunction = s .. options.conjunction .. s
if #list == 2 and string.findsearchDisp(list[1], "§") or #list > 2 then
conjunction = separator .. conjunction
end
end
 
--DRY function
-- Stringifies a list with "and"
function p.andListconjList (conj, list, formattedfmt)
return stringifyList(list, {conjunction = "and"conj, formatted = formattedfmt})
end
 
-- Stringifies a listlists with "and" or "or"
function p.orListandList (list...) return conjList("and", formatted...) end
function p.orList (...) return conjList("or", ...) end
return stringifyList(list, {conjunction = "or", formatted = formatted})
end
 
--------------------------------------------------------------------------------
--default options table used across the forSee family of functions
local forSeeDefaultOptions = {
andKeyword = 'and',
title = mw.title.getCurrentTitle().text,
otherText = 'other uses',
forseeFormforSeeForm = 'For %s, see %s.',
punctuationCollapseReplacements = {
 
--Collapses duplicate punctuation
function punctuationCollapse (text)
local replacements = {
["%.%.$"] = ".",
["%?%.$"] = "?",
["%!%]%]%.$"] = "!]]"
}
for k, v in pairs(replacements) do text = string.gsub(text, k, v) end
return text
end
 
-- Structures arguments into a table for stringification, & options
if type(k) == 'number' and k > maxArg then maxArg = k end
end
-- Structure the data out from the parameter list:
-- * forTable is the wrapper table, with forRow rows
-- * Rows are tables of a "use" string and& a "pages" table of pagename strings
-- * Blanks are left empty for defaulting elsewhere, but can terminate list
local forTable = {}
local i = from
local terminated = false
-- RepeatLoop to generate and append each rowrows
repeat
-- New empty row
local forRow = {}
-- If there's aOn blank use, assume the list's ended, leave& break at end of emptythis forloop
-- defaulting elsewhere, and break at the end of this loop-through.
forRow.use = args[i]
if not args[i] then terminated = true end
-- New empty list of pages
forRow.pages = {}
-- Try to insertInsert first pages item; empty is ignored/defaultedif elsewherepresent
table.insert(forRow.pages, args[i + 1])
-- If the optionparam after next is "and", do an inner loop whereto wecollect collectparams
-- itemsuntil followingthe "and"'s untilstop. theBlanks are ignored: "1|and||and|3"'s stop. If there's a{1, blank3}
while args[i + 2] == 'and'options.andKeyword do
-- where we'd expect an item, ignore it: "1|and||and|3" → {1, 3}
while args[i + 2] == 'and' do
if args[i + 3] then
table.insert(forRow.pages, args[i + 3])
end
-- Increment to the next "and"
i = i + 2
end
-- Increment to the next use
i = i + 2
-- AddAppend the row to the table
table.insert(forTable, forRow)
until terminated or i > maxArg
end
 
-- TakesStringifies a table as formatted by forSeeArgsToTable and stringifies it
function p.forSeeTableToString (forSeeTable, options)
-- Type-checks and defaults
if options[k] == nil then options[k] = v end
end
-- FormatStringify each for-see item and makeinto a table containing themlist
local strList = {}
for k, v in pairs(forSeeTable) do
local pagesStr = p.andList(v.pages, true) or
mHatnote._formatLink(mHatnote.disambiguate(options.title))
local forSeeStr = string.format(options.forseeFormforSeeForm, useStr, pagesStr)
forSeeStr = string.gsubpunctuationCollapse(forSeeStr, k, v)
for k, v in pairs(options.punctuationCollapseReplacements) do
forSeeStr = string.gsub(forSeeStr, k, v)
end
table.insert(strList, forSeeStr)
end
 
-- Produces a "For X, see [[Y]]" string from arguments. Expects index gaps
-- but not blank or /whitespace values;. thoseIgnores shouldnamed beargs filtered.and Ignoresargs < "from".
-- arguments less than "from", and named arguments.
function p._forSee (args, from, options)
local forSeeTable = p.forSeeArgsToTable(args, from, options)
end
 
-- CallsAs _forSee, but pulls fromuses the frame.
function p.forSee (frame, from, options)
mArguments = require('Module:Arguments')
0

edits

"https://te.wikipedia.org/wiki/ప్రత్యేక:MobileDiff/1993440" నుండి వెలికితీశారు