Anonymous user
Module:Lang: Difference between revisions
Jump to navigation
Jump to search
no edit summary
No edit summary |
No edit summary |
||
Line 340:
table.insert (tout, "</span>''");
return table.concat (tout);
--[[--------------------------< V A L I D A T E _ T E X T >---------------------------------------------------
]]
local function validate_text (template, args)
if not is_set (args.text) then▼
end▼
if args.text:find ("\'\'\'\'\'[\']+") then▼
return make_error_msg (table.concat ({'{{
end▼
if args.text:match ("%f[\']\'\'[^\']+\'\'%f[^\']") or args.text:match ("\'\'\'\'\'[^\']+\'\'\'\'\'") then -- italic but not bold or bold italic▼
return make_error_msg (table.concat ({'{{
end▼
if args.text:find ("\'\'\'\'") then -- four apostrophes ▼
return make_error_msg (table.concat ({'{{
end▼
if 'yes' == args.italic then▼
if args.text:sub(1,1) == "'" then▼
args.text = "<span></span>" .. args.text;▼
end▼
if args.text:sub(-1,-1) == "'" then▼
args.text = args.text .. "<span></span>";▼
end▼
end
end
Line 363 ⟶ 396:
if not (code and script and region and variant) then
return make_error_msg (table.concat ({'{{lang}}: unknown language code: ', args.code or 'missing'}), args.
end
▲ if not is_set (args.text) then
▲ return make_error_msg ('{{lang}}: no text', args.no_cat);
▲ end
if not is_set (args.italic) then
args.italic = 'no'; -- DEFAULT for {{lang}} templates is to not italicize
end
local msg = validate_text ('lang', args);
▲ if args.text:match ("%f[\']\'\'[^\']+\'\'%f[^\']") or args.text:match ("\'\'\'\'\'[^\']+\'\'\'\'\'") then -- italic but not bold or bold italic
▲ return make_error_msg ('{{lang-xx}}: text has italic markup', args.no_cat);
return msg;
end
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles
Line 429 ⟶ 459:
if not (code and script and region and variant) then
return make_error_msg (table.concat ({'{{lang-xx}}: unknown language code: ', args.code or 'missing'}), args.
end
local msg = validate_text ('lang-xx', args);
▲ if not is_set (args.text) then
if is_set (msg) then
return msg;
▲ end
▲ if args.text:find ("\'\'\'\'\'[\']+") then
▲ return make_error_msg ('{{lang-xx}}: text has malformed markup', args.no_cat);
▲ end
▲ end
▲ if args.text:find ("\'\'\'\'") then -- four apostrophes
▲ return make_error_msg ('{{lang-xx}}: text has malformed markup', args.no_cat);
▲ end
▲ if 'yes' == args.italic then
▲ if args.text:sub(1,1) == "'" then
▲ args.text = "<span></span>" .. args.text;
▲ end
▲ if args.text:sub(-1,-1) == "'" then
▲ args.text = args.text .. "<span></span>";
▲ end
end
args.code = format_ietf_tag (code, script, region, variant); -- format to recommended subtag styles
|