Module:Footnotes
f = {
 	args_default = {
 		bracket_left = &quot;&quot;,
 		bracket_right = &quot;&quot;,
 		bracket_year_left = &quot;&quot;,
 		bracket_year_right = &quot;&quot;,
 		postscript = &quot;&quot;,
 		page = &quot;&quot;,
 		pages = &quot;&quot;,
 		location = &quot;&quot;,
 		page_sep = &quot;, ப.&amp;nbsp;&quot;,
 		pages_sep = &quot;, ப.&amp;nbsp;&quot;,
 		ref = &quot;&quot;,
 		P1 = &quot;&quot;,
 		P2 = &quot;&quot;,
 		P3 = &quot;&quot;,
 		P4 = &quot;&quot;,
 		P5 = &quot;&quot;
 	}
 };
 
 function trim( str )
 	if str == nil then
 		return nil;
 	end
 	return str:match( &quot;^%s*(.-)%s*$&quot;);
 end    
 
 function core( args )
 	local result;
 
 	if args.P5 ~= &quot;&quot; then
 		result = args.P1 .. ' et al. ' .. args.bracket_year_left .. args.P5 .. 
 		args.bracket_year_right;
 	elseif args.P4 ~= &quot;&quot; then
 		result = args.P1 .. ', ' .. args.P2 .. ' &amp;amp; ' .. args.P3 .. ' ' .. 
 		args.bracket_year_left .. args.P4 .. args.bracket_year_right;
 	elseif args.P3 ~= &quot;&quot; then
 		result = args.P1 .. ' &amp;amp; ' .. args.P2 .. ' ' .. args.bracket_year_left .. 
 		args.P3 .. args.bracket_year_right;
 	else
 		result = trim( args.P1 .. ' ' .. args.bracket_year_left .. args.P2 .. 
 		args.bracket_year_right )
 	end
 
 	if args.ref ~= 'none' then
 		if args.ref ~= &quot;&quot; then
 			result = &quot;[[#&quot; .. mw.uri.anchorEncode(args.ref) .. &quot;|&quot; .. result .. &quot;]]&quot;;
 		else
 			result = &quot;[[#CITEREF&quot; .. mw.uri.anchorEncode(args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5) .. &quot;|&quot; .. result .. &quot;]]&quot;;
 		end
 	end
 
 	if args.page ~= &quot;&quot; then
 		result = result .. args.page_sep .. args.page;
 	elseif args.pages ~= &quot;&quot; then
 		result = result .. args.pages_sep .. args.pages;
 	end      
 
 	if args.location ~= &quot;&quot; then
 		result = result .. &quot;, &quot; .. args.location;
 	end
 
 	result = args.bracket_left .. result .. args.bracket_right .. args.postscript;
 	return result;
 end
 
 function f.harvard_core( frame )
 	local args = {};
 	local pframe = frame:getParent();
 
 	args.bracket_left = pframe.args.BracketLeft or &quot;&quot;;
 	args.bracket_right = pframe.args.BracketRight or &quot;&quot;;
 	args.bracket_year_left = pframe.args.BracketYearLeft or &quot;&quot;;
 	args.bracket_year_right = pframe.args.BracketYearRight or &quot;&quot;;
 	args.postscript = pframe.args.Postscript or &quot;&quot;;
 	if 'none' == args.postscript then
 		args.postscript = '';
 	end
 
 	args.page = pframe.args.Page or &quot;&quot;;
 	args.pages = pframe.args.Pages or &quot;&quot;;
 	args.location = pframe.args.Location or &quot;&quot;;
 	args.page_sep = pframe.args.PageSep or &quot;&quot;;
 	args.pages_sep = pframe.args.PagesSep or &quot;&quot;;
 	args.ref = pframe.args.REF or &quot;{{{REF}}}&quot;;
 	args.P1 = trim( pframe.args.P1 ) or &quot;&quot;;
 	args.P2 = trim( pframe.args.P2 ) or &quot;&quot;;
 	args.P3 = trim( pframe.args.P3 ) or &quot;&quot;;
 	args.P4 = trim( pframe.args.P4 ) or &quot;&quot;;
 	args.P5 = trim( pframe.args.P5 ) or &quot;&quot;;
 
 	return core( args );
 end
 
 function f.harvard_citation( frame )
 	local args = f.args_default;
 	pframe = frame:getParent();
 
 	args.bracket_left = &quot;(&quot;;
 	args.bracket_right = &quot;)&quot;;
 	args.page = pframe.args.p or pframe.args.page or &quot;&quot;;
 	args.pages = pframe.args.pp or pframe.args.pages or &quot;&quot;;
 	args.location = pframe.args.loc or &quot;&quot;;
 	args.ref = pframe.args.ref or pframe.args.Ref or &quot;&quot;;
 	args.P1 = trim( pframe.args[1] ) or &quot;&quot;;
 	args.P2 = trim( pframe.args[2] ) or &quot;&quot;;
 	args.P3 = trim( pframe.args[3] ) or &quot;&quot;;
 	args.P4 = trim( pframe.args[4] ) or &quot;&quot;;
 	args.P5 = trim( pframe.args[5] ) or &quot;&quot;;
 
 	return core( args );
 end
 
 function f.harvard_citation_no_bracket( frame )
 	local args = f.args_default;
 	pframe = frame:getParent();
 
 	args.page = pframe.args.p or pframe.args.page or &quot;&quot;;
 	args.pages = pframe.args.pp or pframe.args.pages or &quot;&quot;;
 	args.location = pframe.args.loc or &quot;&quot;;
 	args.ref = pframe.args.ref or pframe.args.Ref or &quot;&quot;;
 	args.P1 = trim( pframe.args[1] ) or &quot;&quot;;
 	args.P2 = trim( pframe.args[2] ) or &quot;&quot;;
 	args.P3 = trim( pframe.args[3] ) or &quot;&quot;;
 	args.P4 = trim( pframe.args[4] ) or &quot;&quot;;
 	args.P5 = trim( pframe.args[5] ) or &quot;&quot;;
 
 	return core( args );
 end
 
 function f.sfn( frame )
 	local args = f.args_default;
 	for k, v in pairs( frame.args ) do											-- for {{sfnp}}, override default with values provided in the #invoke:
 		args[k] = v;	   
 	end
 	
 	pframe = frame:getParent();
 
 	args.postscript = pframe.args.postscript or pframe.args.ps or &quot;.&quot;;
 	if 'none' == args.postscript then
 		args.postscript = '';
 	end
 	args.page = pframe.args.p or pframe.args.page or &quot;&quot;;
 	args.pages = pframe.args.pp or pframe.args.pages or &quot;&quot;;
 	args.location = pframe.args.loc or &quot;&quot;;
 	args.ref = pframe.args.ref or pframe.args.Ref or &quot;&quot;;
 	args.P1 = trim( pframe.args[1] ) or &quot;&quot;;
 	args.P2 = trim( pframe.args[2] ) or &quot;&quot;;
 	args.P3 = trim( pframe.args[3] ) or &quot;&quot;;
 	args.P4 = trim( pframe.args[4] ) or &quot;&quot;;
 	args.P5 = trim( pframe.args[5] ) or &quot;&quot;;
 
 	local result = core( args );
 	local name = &quot;FOOTNOTE&quot; .. args.P1 .. args.P2 .. 
 	args.P3 .. args.P4 .. args.P5 .. args.page .. args.pages .. args.location;
 
 	result = frame:extensionTag{ name = &quot;ref&quot;, args = {name=name}, content=result };
 
 	return result;
 end