模块:CharInsert:修订间差异
来自 LNN的:not(博客)?
更多操作
小无编辑摘要 |
小无编辑摘要 |
||
| 第10行: | 第10行: | ||
local value = mw.text.encode(str, "&<\t\n\r " .. ustring.char(160)) | local value = mw.text.encode(str, "&<\t\n\r " .. ustring.char(160)) | ||
local link = frame:extensionTag("charinsert", | local nowiki = frame:extensionTag("nowiki", value) | ||
local link = frame:extensionTag("charinsert", nowiki, {label = label}) | |||
return mw.text.tag( "code", {title = title}, link ) | return mw.text.tag( "code", {title = title}, link ) | ||
end | end | ||
| 第23行: | 第24行: | ||
dplUnescape = dplUnescape or require("Module:dpl unescape")._unescape | dplUnescape = dplUnescape or require("Module:dpl unescape")._unescape | ||
str = dplUnescape(str) | str = dplUnescape(str) | ||
end | end | ||
2023年2月21日 (二) 13:27的最新版本
此模块的文档可以在模块:CharInsert/doc创建
local p = {}
local ustring = mw.ustring
local libraryUtil = require("libraryUtil")
local getArgs, yesno, dplUnescape
function p._charInsert(frame, str, label, title)
libraryUtil.checkType( "str", 2, str, "string" )
libraryUtil.checkType( "label", 3, label, "string", --[[nilOk=]] true )
libraryUtil.checkType( "title", 4, title, "string", --[[nilOk=]] true )
local value = mw.text.encode(str, "&<\t\n\r " .. ustring.char(160))
local nowiki = frame:extensionTag("nowiki", value)
local link = frame:extensionTag("charinsert", nowiki, {label = label})
return mw.text.tag( "code", {title = title}, link )
end
function p.charInsert(frame)
getArgs = getArgs or require("Module:Arguments").getArgs
yesno = yesno or require("Module:Yesno")
local args = getArgs(frame)
local str = mw.text.killMarkers(args[1])
if not yesno(args.raw) then
dplUnescape = dplUnescape or require("Module:dpl unescape")._unescape
str = dplUnescape(str)
end
return p._charInsert(frame, str, args.label, args.title)
end
return p