Module:Cite
Appearance
![]() | This Lua module is used on approximately 47,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module should only be used on articles that are near the post-expand include size limit, in order to prevent them exceeding it. Unless there is a pressing technical need, use appropriate cs1 and {{citation}} templates |
![]() | This module depends on the following other modules: |
{{Cite arXiv}} | arXiv preprints |
---|---|
{{Cite AV media}} | audio and visual media |
{{Cite AV media notes}} | AV media liner notes |
{{Cite bioRxiv}} | bioRxiv preprints |
{{Cite book}} | books and chapters |
{{Cite CiteSeerX}} | CiteSeerX papers |
{{Cite conference}} | conference papers |
{{Cite document}} | short, stand-alone, offline documents |
{{Cite encyclopedia}} | edited collections |
{{Cite episode}} | radio or TV episodes |
{{Cite interview}} | interviews |
{{Cite journal}} | academic journals |
{{Cite magazine}} | magazines, periodicals |
{{Cite mailing list}} | public mailing lists |
{{Cite map}} | maps |
{{Cite medRxiv}} | medRxiv preprints |
{{Cite news}} | news articles |
{{Cite newsgroup}} | online newsgroups |
{{Cite podcast}} | podcasts |
{{Cite press release}} | press releases |
{{Cite report}} | reports |
{{Cite serial}} | audio or video serials |
{{Cite sign}} | signs, plaques |
{{Cite speech}} | speeches |
{{Cite SSRN}} | SSRN papers |
{{Cite tech report}} | technical reports |
{{Cite thesis}} | theses |
{{Cite web}} | web sources not covered by the above |
See also | Specific-source templates Citation Style 1 wrapper templates |
Usage
This module may be used to replace any of the cs1|2 templates in articles that are nearing the post-expand include size limit. Such use should only be done to prevent an article from exceeding the PEIS limit. If necessary, this module may be used in templates that wrap a cs1|2 template.
Examples
This module requires no parameters but does require the canonical name of a cs1 template without the cite
prefix: cite book
→ book
, cite web
→ web
. To replace {{citation}}
templates, use citation
.
The structure for calls to this module:
{{#invoke:cite |<template name>|<cs1 parameters>}}
where:
#invoke:cite
– calls this module: Module:cite|<template name>
– is the canonical name of the template without thecite
prefix; this is the#invoke:
function call; case insensitive|<cs1 parameters>
– are all of the parameters required by{{cite <template name>}}
To go from {{cite book}}
:
{{cite book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}
- EB Green (1915). Title. PseudoRandom.
write:
{{#invoke:cite |book |author=EB Green |date=1915 |title=Title |publisher=PseudoRandom}}
- Script error: The function "book" does not exist.
require ('strict');
--[[--------------------------< K N O W N _ T E M P L A T E S _ T >-------------------------------------------
list of all known cs1|2 templates by their canonical names
key is lowercase canonical template name
]]
local known_templates_t = {
['arxiv'] = true,
['av media'] = true,
['av media notes'] = true,
['biorxiv'] = true,
['book'] = true,
['citation'] = true,
['citeseerx'] = true,
['conference'] = true,
['document'] = true,
['encyclopedia'] = true,
['episode'] = true,
['interview'] = true,
['journal'] = true,
['magazine'] = true,
['mailing list'] = true,
['map'] = true,
['medrxiv'] = true,
['news'] = true,
['newsgroup'] = true,
['podcast'] = true,
['press release'] = true,
['report'] = true,
['serial'] = true,
['sign'] = true,
['speech'] = true,
['ssrn'] = true,
['tech report'] = true,
['thesis'] = true,
['web'] = true,
}
--[[--------------------------< C I T A T I O N _ C L A S S E S _ T >-----------------------------------------
|CitationClass= in the cs1|2 templates gets the lowercase template name except for these
key is lowercase canonical template name
]]
local citation_classes_t = { --
['av media'] = 'audio-visual',
['av media notes'] = 'AV-media-notes',
['encyclopedia'] = 'encyclopaedia',
['mailing list'] = 'mailinglist',
['press release'] = 'pressrelease',
['tech report'] = 'techreport',
}
--[[--------------------------< C I T E >---------------------------------------------------------------------
test to prove that Module:Citation/CS1/sandbox can be called from another Module
{{#invoke:Sandbox/trappist the monk/cite|cite|book|title=Title}}
TODO: needs better error handling
]]
local function cite (frame)
local args_t = require ('Module:Arguments').getArgs (frame);
if not args_t[1] then -- this is the template name; we must have a template name
return error ('missing template name as first positional parameter'); -- no template name; abandon with error message
end
local template = args_t[1]:lower(); -- lowercase for table indexes
args_t[1] = nil; -- unset, no longer needed (and would break the cs1|2 template)
if not known_templates_t[template] then -- do we recognize this template name?
return error ('unknown template name: ' .. template); -- nope; abandon with error message
end
local config_t = {['CitationClass'] = citation_classes_t[template] or template};
return require ('Module:Citation/CS1/sandbox')._citation (nil, args_t, config_t);
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
return {
cite = cite,
}