Content deleted Content added
other cases |
right |
||
Line 201:
-- Additionally check how many digits we actually have, as arbitrary number isn't valid
if (#foundMatch <= 2) then -- most likely a day number or time number
return ELEMENT_ONETWODIGITS, tonumber(foundMatch), (currentPosition > mw.ustring.len(seekString))
elseif (#foundMatch == 4) then -- most likely a year
return ELEMENT_FOURDIGITS, tonumber(foundMatch), (currentPosition > mw.ustring.len(seekString))
else
return ELEMENT_INVALID -- just the invalid, the number of digits (3 or 5+) won't match any
end
end
Line 239:
end
-- Time separator (colon without whitespace)▼
foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(:)', currentPosition)▼
if (foundPositionStart) then▼
currentPosition = foundPositionEnd + 1 -- this is our new start ___location▼
return ELEMENT_TIMESEPARATOR, foundMatch, (currentPosition > mw.ustring.len(seekString))▼
end▼
-- Comma and any following whitespace▼
foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(,%s*)', currentPosition)▼
if (foundPositionStart) then▼
currentPosition = foundPositionEnd + 1 -- this is our new start ___location▼
return ELEMENT_COMMA, foundMatch, (currentPosition > mw.ustring.len(seekString))▼
end▼
-- Dash with possible whitespace or Date separator (dash without whitespace)
foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(%s*[%-–—]%s*)', currentPosition)
Line 251 ⟶ 265:
end
-- Same but non-breaking space - ' - '
foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(
if (foundPositionStart) then
currentPosition = foundPositionEnd + 1 -- this is our new start ___location
Line 269 ⟶ 283:
end
-- Same but dash entity code and non-breaking space - ' – '
foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(
if (foundPositionStart) then
currentPosition = foundPositionEnd + 1 -- this is our new start ___location
Line 279 ⟶ 293:
currentPosition = foundPositionEnd + 1 -- this is our new start ___location
return ELEMENT_DASH, foundMatch, (currentPosition > mw.ustring.len(seekString))
▲ end
▲ -- Time separator (colon without whitespace)
▲ foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(:)', currentPosition)
▲ if (foundPositionStart) then
▲ currentPosition = foundPositionEnd + 1 -- this is our new start ___location
▲ return ELEMENT_TIMESEPARATOR, foundMatch, (currentPosition > mw.ustring.len(seekString))
▲ end
▲ -- Comma and any following whitespace
▲ foundPositionStart, foundPositionEnd, foundMatch = mw.ustring.find(seekString, '^(,%s*)', currentPosition)
▲ if (foundPositionStart) then
▲ currentPosition = foundPositionEnd + 1 -- this is our new start ___location
▲ return ELEMENT_COMMA, foundMatch, (currentPosition > mw.ustring.len(seekString))
end
|