Content deleted Content added
Improve fileargs handling: when adding |left to image specification, remove |right, etc. |
Add per-page options |
||
Line 568:
local pagecount = #pagenames
local firstpage = pagenames[1] or "(nil)" -- save for error message, as it the name will be deleted
local gotopt
local pageoptstr
-- read the page, or a random one if multiple pages were provided
Line 576 ⟶ 578:
pagename = pagenames[pagenum]
if pagename and pagename ~= "" then
-- We have page or [[page]] or [[page|text]], possibly followed by |opt1|opt2...
pagename = mw.ustring.match(pagename, "%[%[%s*(.-)[%]|]") or pagename -- "[[Foo|Bar]]" → "Foo"▼
local pn
if pn then
▲ pagename = mw.ustring.match(
else -- we have page or page|opt...
pagename, gotopt, pageoptstr = mw.ustring.match(pagename, "%s*([^|]*[^|%s])%s*(|?)(.*)")
end
if pagename and pagename ~= "" then
Line 605 ⟶ 612:
text = cleanupText(text, true)
local pageopts = {} -- pageopts (even if value is "") have priority over global options
for k, v in pairs(options) do pageopts[k] = v end
if gotopt and gotopt ~= "" then
for _, t in pairs(mw.text.split(pageoptstr, "|")) do
local k, v = mw.ustring.match(t, "%s*([^=]-)%s*=(.-)%s*$")
pageopts[k] = v
end
pageopts.paraflags = numberflags(pageopts["paragraphs"] or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
pageopts.fileflags = numberflags(pageopts["files"] or "") -- parse file numbers
if pageopts.more and pageopts.more == "" then pageopts.more = "Read more..." end -- more= is short for this default text
end
local filetext
filetext, text = parse(text,
-- replace the bold title or synonym near the start of the article by a wikilink to the article
Line 645 ⟶ 665:
text = fixtags(text, "div")
if
return text
end
|