Module:Lang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
No edit summary |
||
Line 204: | Line 204: | ||
table.insert (out, '</span>'); |
table.insert (out, '</span>'); |
||
if (0 == namespace) and not is_set (nocat) then -- only categorize in article space |
|||
table.insert (out, '[[Category:lang and lang-xx template errors]]'); |
table.insert (out, '[[Category:lang and lang-xx template errors]]'); |
||
end |
|||
return table.concat (out); |
return table.concat (out); |
||
Line 304: | Line 304: | ||
local title; |
local title; |
||
local tout = {}; |
local tout = {}; |
||
local title_table = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards |
local title_table = lang_data.translit_title_table; -- table of transliteration standards and the language codes and scripts that apply to those standards |
||
table.insert (tout, "''<span title=\""); |
table.insert (tout, "''<span title=\""); |
||
Line 344: | Line 344: | ||
--[[--------------------------< V A L I D A T E _ T E X T >--------------------------------------------------- |
--[[--------------------------< V A L I D A T E _ T E X T >--------------------------------------------------- |
||
This function checks the content of args.text and returns empty string if nothing is amiss else it returns an |
|||
error message. The tests are for empty or missing text and for improper or disallowed use of apostrophe markup. |
|||
Italic rendering is controlled by the |italic= template parameter so italic markup should never appear in args.text |
|||
either as ''itself''' or as '''''bold italic'''''. |
|||
Also protects single leading and trailing single quote marks from being converted to bold by the addition of |
|||
adjacent italic markup. |
|||
]] |
]] |
||
Line 352: | Line 361: | ||
end |
end |
||
if args.text:find ("\'\'\'\'\'[\']+") then |
if args.text:find ("\'\'\'\'\'[\']+") then -- because we're looking, look for 6+ appostrophes |
||
return make_error_msg (table.concat ({'{{', template, '}}: text has malformed markup'}), args.nocat); |
return make_error_msg (table.concat ({'{{', template, '}}: text has malformed markup'}), args.nocat); |
||
end |
end |
||
if args.text:match ("%f[\']\'\'[^\']+\'\'%f[^\']") or args.text:match ("\'\'\'\'\'[^\']+\'\'\'\'\'") then -- italic but not bold or bold italic |
if args.text:match ("%f[\']\'\'[^\']+\'\'%f[^\']") or args.text:match ("\'\'\'\'\'[^\']+\'\'\'\'\'") then -- italic but not bold, or bold italic |
||
return make_error_msg (table.concat ({'{{', template, '}}: text has italic markup'}), args.nocat); |
return make_error_msg (table.concat ({'{{', template, '}}: text has italic markup'}), args.nocat); |
||
end |
end |
||
if args.text:find ("\'\'\'\'") then -- |
if args.text:find ("\'\'\'\'") then -- because we're looking, look for 4 apostrophes |
||
return make_error_msg (table.concat ({'{{', template, '}}: text has malformed markup'}), args.nocat); |
return make_error_msg (table.concat ({'{{', template, '}}: text has malformed markup'}), args.nocat); |
||
end |
end |
||
if 'yes' == args.italic then |
if 'yes' == args.italic then -- protect single quote marks from being converted to bold markup |
||
args.text = args.text:gsub ("^\'[^\']+", "<span></span>%1"); -- leading single quote mark |
|||
args.text = args.text:gsub ("[^\']+\'$", "%1<span></span>"); -- trailing single quote mark |
|||
end |
|||
if args.text:sub(-1,-1) == "'" then |
|||
args.text = args.text .. "<span></span>"; |
|||
end |
|||
end |
end |
||
end |
end |