Content deleted Content added
Handle <math foo="bar"> like <math>; test case Commensurability (mathematics) |
Exclude following | or }} from alt text, after accepting embedded {{foo|bar}} etc. Test case: Quickplay Media on Portal:AT&T |
||
Line 181:
for position, altText in mw.ustring.gmatch(text, "|%s*[Aa][Ll][Tt]%s*=%s*()([^\n]*)") do
if altText then
-- altText is terminated by }} or |, but first skip any matched [[...]] and {{...}}
local lookfrom = math.max( -- find position after whichever comes last: start of string, end of last ]] or end of last }}
mw.ustring.find(altText, ".*{%b{}}()") or 1, -- if multiple {{...}}, .* consumes all but one, leaving the last for %b
mw.ustring.find(altText, ".*%[%b[]%]()") or 1)
local len = mw.ustring.len(altText)
local aftertext = math.min( -- find position after whichever comes first: end of string, }} or |
mw.ustring.find(altText, "()}}", lookfrom) or len+1,
mw.ustring.find(altText, "()|", lookfrom) or len+1)
altText = mw.ustring.sub(altText, 1, aftertext-1) -- chop off |... or }}... which is not part of [[...]] or {{...}}
altText = mw.text.trim(altText)
local altTextStart = mw.ustring.sub(altText, 1, 1)
|