Module:Excerpt: Difference between revisions

Content deleted Content added
Prevent side-effects of frame:preprocess on image descriptions, such as setting DEFAULTSORT
Ignore File: text when linking bold title
Line 468:
until not text or text == "" or not token or token == "" -- loop until all text parsed
 
text = mw.ustring.gsub(filetext .. t, "\n+$", "") -- remove trailing line feeds, so "{{Transclude text excerpt|Foo}} more" flows on one line
return textfiletext, leadstarttext
end
 
Line 553:
 
text = cleanupText(text, true)
local filetext
textfiletext, leadstarttext = parse(text, options)
 
-- replace the bold title or synonym near the start of the article by a wikilink to the article
Line 563 ⟶ 564:
text = mw.ustring.sub(text, 1, pos + 2) .. "[[" .. mw.ustring.sub(text, pos + 3, pos + len + 2) .. "]]" .. mw.ustring.sub(text, pos + len + 3, -1) -- link it
else -- look for anything unlinked in bold, assumed to be a synonym of the title (e.g. a person's birth name)
text = mw.ustring.gsub(text, "(.-)''')(.-'*)'''", function(a, b)
if mw.ustring.len(a) < 100 + (leadstart or 0) and not mw.ustring.find(b, "%[") then ---if early in article and not wikilinked
return a .. "'''[[" .. pagename .. "|" .. b .. "]]'''" -- replace '''Foo''' by '''[[pagename|Foo]]'''
else
return nil -- instruct gsub to make no change
Line 571 ⟶ 572:
end, 1) -- "end" here terminates the anonymous replacement function(a, b) passed to gsub
end
 
text = filetext .. text
 
-- Seek and destroy unterminated templates and wikilinks