Content deleted Content added
Sophivorus (talk | contribs) Rename most variables to camelCase for inner consistency and with general Lua and MediaWiki style and better readability on long variable names. Also un-abbreviated a few variable names, again for better readability and hopefully easier onboarding of new developers. |
Sophivorus (talk | contribs) Rename a few more variables. Getting ready to split abstract functions from template-specific functions |
||
Line 141:
local argname, position, image = mw.ustring.match(text, "|%s*([^=|]-[Ii][Mm][Aa][Gg][Ee][^=|]-)%s*=%s*()(.*)", captureFrom)
if image then -- ImageCaption=, image_size=, image_upright=, etc. do not introduce an image
local
if mw.ustring.find(
or mw.ustring.find(
or mw.ustring.find(
image = nil
end
Line 219:
-- altText is terminated by }} or |, but first skip any matched [[...]] and {{...}}
local
mw.ustring.match(altText, ".*{%b{}}()") or 1, -- if multiple {{...}}, .* consumes all but one, leaving the last for %b
mw.ustring.match(altText, ".*%[%b[]%]()") or 1)
local length = mw.ustring.len(altText)
local
mw.ustring.match(altText, "()}}",
mw.ustring.match(altText, "()|",
altText = mw.ustring.sub(altText, 1,
altText = mw.text.trim(altText)
Line 690:
-- Shared template invocation code for lead and random functions
local function invoke(frame,
-- args = { 1,2,... = page names, paragraphs = list e.g. "1,3-5", files = list, more = text}
local args = {} -- args[k] = frame.args[k] or frame:getParent().args[k] for all k in either (numeric or not)
Line 697:
errors = args["errors"] -- set the module level boolean used in local function err
local
if
return err("No articles provided")
end
local pageNames = {}
if
pageNames = { args[1] }
elseif
-- Read named page and find its wikilinks
local page = args[1]
Line 720:
-- replace annotated links with real links
text = mw.ustring.gsub(text, "{{%s*[Aa]nnotated[ _]link%s*|%s*(.-)%s*}}", "[[%1]]")
if
for p in mw.ustring.gmatch(text, "%[%[%s*([^%]|\n]*)") do table.insert(pageNames, p) end
else -- listitem: first wikilink on a line beginning *, :#, etc. except in "See also" or later section
Line 726:
for p in mw.ustring.gmatch(text, "\n:*[%*#][^\n]-%[%[%s*([^%]|\n]*)") do table.insert(pageNames, p) end
end
elseif
-- accept any number of page names. If more than one, we'll pick one randomly
for i, p in pairs(args) do
if p and type(i) == 'number' then table.insert(pageNames, p) end
end
elseif
local
if tonumber(
if
end
pageNames = { args[
end
Line 805:
options.paraflags = numberFlags(args.paragraphs or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
options.fileflags = numberFlags(args.files or "1") -- parse file numbers
options.nobold = 1
options.keepTables = is(args.tables) and args.tables or 1
options.keepRefs = is(args.references) and args.references or 1
|