end  
code = code:lower; -- ensure that we use and return lower case version of this  
if not (override_table[code] or lang_table[code] or synonym_table[code] or lang_dep_table[code]) then
return nil, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_code, {code}); -- invalid language code, don't know about the others (don't care?)
end  
if synonym_table[code] then -- if 639-2/639-2T code has a 639-1 synonym
table.insert (maint_cats, substitute (cfg.get_ietf_parts_t.maint_promo_cat, {code}));
table.insert (maint_msgs, substitute (cfg.get_ietf_parts_t.maint_promo_msg, {code, synonym_table[code]}));
code = synonym_table[code]; -- use the synonym
end  
if is_set (script) then
if is_set (args_script) then
return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_scr; -- both code with script and |script= not allowed
end
else
script = args_script or ''; -- use args.script if provided
end  
if is_set (script) then
script = script:lower; -- ensure that we use and return lower case version of this
if not script_table[script] then
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_scr_code, {script, code}); -- language code ok, invalid script, don't know about the others (don't care?)
end
end
if suppressed_table[script] then -- ensure that code-script does not use a suppressed script
if in_array (code, suppressed_table[script]) then
return code, nil, nil, nil, nil, substitute (cfg.get_ietf_parts_t.script_code, {script, code}); -- language code ok, script is suppressed for this code
end
end  
if is_set (region) then
if is_set (args_region) then
return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_reg; -- both code with region and |region= not allowed
end
else
region = args_region or ''; -- use args.region if provided
end  
if is_set (region) then
region = region:lower; -- ensure that we use and return lower case version of this
if not region_table[region] then
return code, script, nil, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_reg_code, {region, code});
end
end  
if is_set (variant) then
if is_set (args_variant) then
return code, nil, nil, nil, nil, cfg.get_ietf_parts_t.redundant_var; -- both code with variant and |variant= not allowed
end
else
variant = args_variant or ''; -- use args.variant if provided
end  
if is_set (variant) then
variant = variant:lower; -- ensure that we use and return lower case version of this
if not variant_table[variant] then -- make sure variant is valid
return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var, {variant});
end -- does this duplicate/replace tests in lang and lang_xx?
if is_set (script) then -- if script set it must be part of the 'prefix'
if not in_array (table.concat ({code, '-', script}), variant_table[variant]['prefixes']) then
return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code_scr, {variant, code, script});
end
elseif is_set (region) then -- if region set, there are some prefixes that require lang code and region (en-CA-newfound)
if not in_array (code, variant_table[variant]['prefixes']) then -- first see if lang code is all that's required (en-oxendict though en-GB-oxendict is preferred)
if not in_array (table.concat ({code, '-', region}), variant_table[variant]['prefixes']) then -- now try for lang code and region (en-CA-newfound)
return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code_reg, {variant, code, region});
end
end
else -- cheap way to determine if there are prefixes; fonipa and others don't have prefixes; # operator always returns 0
if variant_table[variant]['prefixes'][1] and not in_array (code, variant_table[variant]['prefixes']) then
return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_var_code, {variant, code});
end
end
end  
if is_set (private) then
private = private:lower; -- ensure that we use and return lower case version of this
if not override_table[table.concat ({code, '-x-', private})] then -- make sure private tag is valid; note that index
return code, script, region, nil, nil, substitute (cfg.get_ietf_parts_t.unrecog_pri, {private});
end
end
return code, script, region, variant, private, nil; -- return the good bits; make sure that msg is nil
end  
--[=[-------------------------< M A K E _ W I K I L I N K >----------------------------------------------------  
Makes a wikilink; when both link and display text is provided, returns a wikilink in the form D; if only
link is provided, returns a wikilink in the form L; if neither are provided or link is omitted, returns an
empty string.  
]=]  
local function make_wikilink (link, display)
if is_set (link) then
if is_set (display) then
return table.concat ({*, display, *});
else
return table.concat ({*, link, *});
end
else
return '';
end
end  
----------------------------< D I V _ M A R K U P _ A D D >--------------------------------------------------  
Adds <i> and </i> tags to list-item text or to implied <p>..</p> text. Mixed not supported.  
local function div_markup_add (text, style)
if text:find ('^\n[%*:;#]') then -- look for list markup; list markup must begin at start of text
if 'italic' == style then
return text:gsub ('(\n[%*:;#]+)([^\n]+)', '%1<i>%2</i>'); -- insert italic markup at each list item
else
return text;
end
end  
if text:find ('\n+') then -- look for any number of \n characters in text
text = text:gsub ('([^\n])\n([^\n])', '%1 %2'); -- replace single newline characters with a space character which mimics mediawiki  
if 'italic' == style then
text = text:gsub('[^\n]+', '<p><i>%1</i></p>'); -- insert p and italic markup tags at each impled p (two or more consecutive '\n\n' sequences)
else
text = text:gsub ('[^\n]+', '<p>%1</p>'); -- insert p markup at each impled p
text = text:gsub ('\n', ''); -- strip newline characters
end
end  
return text;
end  
----------------------------< T I T L E _ W R A P P E R _ M A K E >------------------------------------------  
Makes a <span title="<title text>"><content_text></span> or <div title="<title text>"><content_text></div> where
<title text> is in the tool-tip in the wiki's local language and <content_text> is non-local-language text in
html markup. This because the lang= attibute applies to the content of its enclosing tag.  
<tag> holds a string 'div' or 'span' used to choose the correct wrapping tag.  
local function title_wrapper_make (title_text, content_text, tag)
local wrapper_t = {};  
table.insert (wrapper_t, table.concat ({'<', tag})); -- open opening wrapper tag
table.insert (wrapper_t, ' title=\"'); -- begin title attribute
table.insert (wrapper_t, title_text); -- add <title_text>
table.insert (wrapper_t, '\">'); -- end title attribute and close opening wrapper tag
table.insert (wrapper_t, content_text); -- add <content_text>
table.insert (wrapper_t, table.concat ({'</', tag, '>'})); -- add closing wrapper tag  
return table.concat (wrapper_t); -- make a big string and done
end  
----------------------------< M A K E _ T E X T _ H T M L >--------------------------------------------------  
Add the html markup to text according to the type of content that it is: <span> or <i> tags for inline content or
<div> tags for block content  
The lang= attribute also applies to the content of the tag where it is placed so this is wrong because 'Spanish
language text' is English:
<i lang="es" title="Spanish language text">casa</i>
should be:
<span title="Spanish language text"><i lang="es">casa</i></span>
or for <div>...</div>:
<div title="Spanish language text"><div lang="es"><spanish-language-text></div></div>  
local function make_text_html (code, text, tag, rtl, style, size, language)
local html_t = {};
local style_added = '';
local wrapper_tag = tag; -- <tag> gets modified so save a copy for use when/if we create a wrapper span or div  
if text:match ('^%*') then