Content deleted Content added
other type of tag not supported |
place variant tags in array if there is more than one |
||
Line 356:
end
local parsed_subtags_mt = {
throw = function (self, error, index)
end,▼
remove_unnecessary_fields = function (self)
end,▼
}
}
__call = function (self, input)
▲ self.error = error
▲ self.invalid = table.concat(self.input, "-", index)
end▼
▲ return self:remove_unnecessary_fields()
})
▲end
▲ -- Only useful internally.
▲ self.input = nil
▲ return setmetatable(self, nil)
▲end
▲ return setmetatable({ input = input }, self)
▲end
Line 393 ⟶ 395:
-- are not needed on Wikipedia. Does not recognize "grandfathered" tags.
-- https://www.rfc-editor.org/rfc/rfc6067.txt, https://tools.ietf.org/html/bcp47
-- Only checks that the syntax is correct, not that the values are valid. For
-- instance, does not check that a language code actually exists.
function p.parse_IETF(tag)
if type(tag) ~= "string" or tag == "" then
Line 447 ⟶ 452:
type = subtag_info[index].type
matched = true
-- There can be multiple "variant" subtags (and "extension"
-- subtags, if those are added)
if type ~= "variant" then
index = index + 1
end
break
end
Line 460 ⟶ 470:
if type then
if parsed_subtags[type]
parsed_subtags[type] = { parsed_subtags[type] }
table.insert(parsed_subtags[type], subtag)
else
parsed_subtags[type] = subtag
end
last_matched_subtag_i = subtag_i
matched_count = matched_count + 1
|