Content deleted Content added
m I mean avoid ending author abbreviation |
try array-based output (efficiency difference not noticeable), reject input if two author citations are found in a row (if that's possible) |
||
Line 51:
function p.transform_author_abbrevs(citation, func)
local pos = 1
local output = {}
local remaining = citation
pos = advance_pos_if_starts_with(citation, "%s*[(),&]%s*", pos)▼
while #remaining > 0 do
local author_end = p.find_end_of_author_citation(citation, pos)▼
local orig_pos = pos
if orig_pos == pos and #output > 0 then
return nil
end
if not author_end then
return nil
end
▲ mw.ustring.sub(citation, pos, author_end),
pos = 1
▲ author = func(author) or author
end
if
return
end
end
|