Content deleted Content added
+suppressed script extraction; |
optimizations |
||
Line 41:
local in_comments = false;
if string.find (record, 'Deprecated', 1, true) or string.find (record, 'Preferred
or string.find (record, 'Private use', 1, true) then return 'skip';
end
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
local before_colon = string.match(line, "(.-):")
if string.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line▼
code = string.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code▼
descriptions[#descriptions] = string.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description▼
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. string.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark▼
▲
local desc = string.match (line, 'Description: (.+)'); -- extract the description
desc = string.gsub (desc, '"', '\\"'); -- in case description contains quote marks (see 1959acad)
table.insert (descriptions, '\"' .. desc .. '\"'); -- save the description wrapped in quote marks
elseif
table.insert (prefixes, '\"' .. string.match (line, 'Prefix: (.+)'):lower() .. '\"'); -- extract and save the prefix wrapped in quote marks
elseif
in_comments = true;
▲ descriptions[#descriptions] = string.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
▲ descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. string.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
end
end
Line 106 ⟶ 109:
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
local before_colon = string.match(line, "(.-):")
▲ if string.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
elseif before_colon == 'Description' then -- if this line is a description line
table.insert (descriptions, '\"' .. string.match (line, 'Description: (.+)') .. '\"'); -- extract and save the name wrapped in quote marks
elseif
suppress = string.match (line, 'Suppress%-Script: (%S+)');
elseif
in_comments = true;
elseif string.find (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
Line 154 ⟶ 158:
for record in string.gmatch (content, '%%%%([^%%]+)') do -- get a %% delimited 'record' from the file; leave off the delimiters
if record_type == 'language' then -- if a language record
code, descriptions, suppress = get_lang_script_region_parts (record); -- get the code, description(s), and suppress script
Line 175 ⟶ 180:
end
elseif
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
Line 184 ⟶ 189:
end
elseif
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
Line 193 ⟶ 198:
end
elseif
code, prefixes, descriptions = get_variant_parts (record); -- get the code, prefix(es), and description(s)
|