模組:Cite
外觀

![]() | 本模組應僅在條目接近模板展開後長度超過限制時使用,以防止超出限制。除非存在緊急技術需求,否則應使用常規的cs1系列模板或{{citation}} 模板 |
![]() | 此模組使用Lua語言: |
{{Cite arXiv}} | arXiv預印本 |
---|---|
{{Cite AV media}} | 影音媒體 |
{{Cite AV media notes}} | 影音媒體內頁說明 |
{{Cite bioRxiv}} | bioRxiv預印本 |
{{Cite book}} | 書籍 |
{{Cite citeseerx}} | CiteSeerX論文 |
{{Cite conference}} | 會議論文 |
{{Cite encyclopedia}} | 引用百科全書的資料 |
{{Cite episode}} | 廣播和電視節目 |
{{Cite interview}} | 訪談 |
{{Cite journal}} | 學術期刊 |
{{Cite magazine}} | 雜誌和期刊 |
{{Cite mailing list}} | 公共郵件列表 |
{{Cite map}} | 地圖 |
{{Cite news}} | 新聞報導 |
{{Cite newsgroup}} | 線上新聞群組 |
{{Cite podcast}} | 播客 |
{{Cite press release}} | 新聞稿 |
{{Cite report}} | 報告 |
{{Cite serial}} | 廣播和電視節目系列 |
{{Cite sign}} | 標誌、匾額、銘牌或徽章 |
{{Cite speech}} | 演講 |
{{Cite ssrn}} | SSRN論文 |
{{Cite techreport}} | 技術報告 |
{{Cite thesis}} | 學位論文 |
{{Cite tweet}} | Twitter推文 |
{{Cite web}} | 上述模板未包含的其他網路資料 |
參見 | |
用法
[編輯]本模組可用於替換接近模板展開後長度超過限制的條目中的任何cs1/2系列模板。此類使用應僅用於防止條目超出模板限制。必要時,本模組也可用於封裝cs1/2模板的模板中。
範例
[編輯]本模組不需要特殊參數,但需要指定cs1模板的規範名稱(不帶cite
前綴):cite book
→ book
,cite web
→ web
。替換{{citation}}
模板時使用citation
。
模組調用結構:
{{#invoke:cite |<模板名称>|<cs1参数>}}
其中:
#invoke:cite
– 調用本模組|<模板名称>
– 不帶cite
前綴的模板規範名稱(不區分大小寫)|<cs1参数>
–{{cite <模板名称>}}
所需的所有參數
從{{cite book}}
轉換:
{{cite book |author=作者 |date=1915 |title=標題 |publisher=範例出版社}}
- 作者. 标题. 範例出版社. 1915.
使用:
{{#invoke:cite |book |author=作者 |date=1915 |title=標題 |publisher=範例出版社}}
- Module:Citation/CS1第1759行Lua錯誤:assign to undeclared variable 'citation'
require ('strict');
local cfg = mw.loadData ('Module:Cite/config');
--[[--------------------------< S U B S T I T U T E >----------------------------------------------------------
Substitutes $1, $2, etc in <message> with data from <data_t>. Returns plain-text substituted string when
<data_t> not nil; returns <message> else.
]]
local function substitute (message, data_t)
return data_t and mw.message.newRawMessage (message, data_t):plain() or message;
end
--[[--------------------------< M A K E _ E R R O R _ M S G >--------------------------------------------------
Assembles an error message from module name, message text, help link, and error category.
]]
local function make_error_msg (frame, msg)
local module_name = frame:getTitle(); -- get the module name for prefix and help-link label
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
local category_link = (0 == namespace) and substitute ('[[Category:$1]]', {cfg.settings_t.err_category}) or '';
return substitute ('<span style="color:#d33">Error: {{[[$1|#invoke:$2]]}}: $3 ([[:$4|$5]])</span>$6',
{
module_name, -- the module name with namespace
module_name:gsub ('Module:', ''), -- the module name without namespace
msg, -- the error message
cfg.settings_t.help_text_link, -- help wikilink to text at help page
cfg.settings_t.help, -- help wikilink display text
category_link -- link to error category (for main namespace errors only)
})
end
--[[--------------------------< C I T E >---------------------------------------------------------------------
Function to call Module:Citation/CS1/sandbox with appropriate parameters. For use when an article exceeds the
post-expand include size limit.
{{#invoke:cite|book|title=Title}}
]]
local function cite (frame, template)
local args_t = require ('Module:Arguments').getArgs (frame, {frameOnly=true});
template = template:lower(); -- lowercase for table indexes
if not cfg.known_templates_t[template] then -- do we recognize this template name?
return make_error_msg (frame, substitute (cfg.settings_t.unknown_name, {template})); -- nope; abandon with error message
end
local config_t = {['CitationClass'] = cfg.citation_classes_t[template] or template}; -- set CitationClass value
return require ('Module:Citation/CS1')._citation (nil, args_t, config_t); -- go render the citation
end
--[[--------------------------< E X P O R T S >---------------------------------------------------------------
]]
local p = {};
local function index (_, template) -- This function gets called by the metatable as index(table, key)
return function (frame) return cite (frame, template) end; -- Return a function which calls cite() with the key name
end
local metatable = {['__index'] = index} -- Set __index, which is returned if table[key] is nil, to the index function
setmetatable (p, metatable) -- Assign the metatable to the returned table
return p