Editing Module:Citation/CS1/Utilities
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 13: | Line 13: | ||
]] | ]] | ||
− | local cfg; -- table of tables imported from | + | local cfg; -- table of tables imported from slected Module:Citation/CS1/Configuration |
Line 19: | Line 19: | ||
Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string. | Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string. | ||
+ | This function is global because it is called from both this module and from Date validation | ||
]] | ]] | ||
− | |||
local function is_set( var ) | local function is_set( var ) | ||
return not (var == nil or var == ''); | return not (var == nil or var == ''); | ||
Line 62: | Line 62: | ||
]] | ]] | ||
− | |||
local function error_comment( content, hidden ) | local function error_comment( content, hidden ) | ||
return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content ); | return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content ); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 95: | Line 73: | ||
]] | ]] | ||
− | |||
local function set_error( error_id, arguments, raw, prefix, suffix ) | local function set_error( error_id, arguments, raw, prefix, suffix ) | ||
local error_state = cfg.error_conditions[ error_id ]; | local error_state = cfg.error_conditions[ error_id ]; | ||
Line 103: | Line 80: | ||
if error_state == nil then | if error_state == nil then | ||
− | error( cfg.messages['undefined_error'] ); | + | error( cfg.messages['undefined_error'] ); |
elseif is_set( error_state.category ) then | elseif is_set( error_state.category ) then | ||
table.insert( z.error_categories, error_state.category ); | table.insert( z.error_categories, error_state.category ); | ||
Line 109: | Line 86: | ||
local message = substitute( error_state.message, arguments ); | local message = substitute( error_state.message, arguments ); | ||
− | + | ||
− | + | message = message .. " ([[" .. cfg.messages['help page link'] .. | |
− | + | "#" .. error_state.anchor .. "|" .. | |
− | + | cfg.messages['help page label'] .. "]])"; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
z.error_ids[ error_id ] = true; | z.error_ids[ error_id ] = true; | ||
Line 306: | Line 266: | ||
Gets the display text from a wikilink like [[A|B]] or [[B]] gives B | Gets the display text from a wikilink like [[A|B]] or [[B]] gives B | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
]=] | ]=] | ||
Line 319: | Line 273: | ||
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1"); | return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1"); | ||
end)); | end)); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 368: | Line 284: | ||
local function set_selected_modules (cfg_table_ptr) | local function set_selected_modules (cfg_table_ptr) | ||
cfg = cfg_table_ptr; | cfg = cfg_table_ptr; | ||
− | |||
end | end | ||
Line 381: | Line 296: | ||
select_one = select_one, | select_one = select_one, | ||
add_maint_cat = add_maint_cat, | add_maint_cat = add_maint_cat, | ||
− | wrap_style = wrap_style | + | wrap_style = wrap_style; |
− | safe_for_italics = safe_for_italics | + | safe_for_italics = safe_for_italics; |
− | remove_wiki_link = remove_wiki_link | + | remove_wiki_link = remove_wiki_link; |
− | + | set_selected_modules = set_selected_modules; | |
− | |||
− | set_selected_modules = set_selected_modules | ||
z = z, | z = z, | ||
} | } |