Content deleted Content added
Major overhaul to deal with more permutations of templates, comments and images preceding the desired text |
Add more= option |
||
Line 64:
text = mw.ustring.gsub(t, "\n+$", "") -- remove trailing line feeds, so "{{Transclude text excerpt|Foo}} more" flows on one line
if options.more then text = text .. " '''[[" .. pagename .. "|" .. options.more .. "]]'''" end
return text
end
Line 83 ⟶ 85:
-- Entry point for template callers using #invoke:
function p.lead(frame)
-- args = { 1 = page name, paragraphs = list e.g. "1,3-5", files = list, more = text}
local args = frame.args -- from calling module
local pargs = frame:getParent().args -- from template
Line 90 ⟶ 92:
pagename = mw.ustring.match(pagename, "%[%[%s*(.-)[]|#]") or pagename -- "[[Foo|Bar]]" → "Foo"
local options = {}
local paraflags = p.numberflags(args["paragraphs"] or pargs["paragraphs"] or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}▼
▲
options.more = args["more"] or pargs["more"]
if options.more and options.more == "" then options.more = "Read more..." end -- more= is short for this default text
local text = p._lead(pagename,
return frame:preprocess(text)
end
|