Module:ISBNformatter:修订间差异

来自有兽档案馆
(// Edit via Wikiplus)
(// Edit via Wikiplus)
 
(未显示同一用户的1个中间版本)
第5行: 第5行:


local text = args[1]
local text = args[1]

if mw.ustring.sub(text, 1, 4) == 'ISBN' then
return text
end


local ISBN = {}
local ISBN = {}

ISBN[#ISBN+1] = mw.ustring.sub(text, 1, 3)
ISBN[#ISBN+1] = '-'
ISBN[#ISBN + 1] = 'ISBN '
ISBN[#ISBN+1] = mw.ustring.sub(text, 4, 4)
ISBN[#ISBN + 1] = mw.ustring.sub(text, 1, 3)
ISBN[#ISBN+1] = '-'
ISBN[#ISBN + 1] = '-'
ISBN[#ISBN+1] = mw.ustring.sub(text, 5, 8)
ISBN[#ISBN + 1] = mw.ustring.sub(text, 4, 4)
ISBN[#ISBN+1] = '-'
ISBN[#ISBN + 1] = '-'
ISBN[#ISBN+1] = mw.ustring.sub(text, 9, 12)
ISBN[#ISBN + 1] = mw.ustring.sub(text, 5, 8)
ISBN[#ISBN+1] = '-'
ISBN[#ISBN + 1] = '-'
ISBN[#ISBN+1] = mw.ustring.sub(text, 13)
ISBN[#ISBN + 1] = mw.ustring.sub(text, 9, 12)
ISBN[#ISBN + 1] = '-'
ISBN[#ISBN + 1] = mw.ustring.sub(text, 13)


return table.concat(ISBN)
return table.concat(ISBN)

2023年8月23日 (三) 16:34的最新版本

文档图示 模块文档[创建] [跳转到代码]

本模块还没有文档页面。

您可以创建文档以让编者更好地理解本模块的用途。
编者可以在本模块的沙盒创建 | 镜像和测试样例创建页面进行实验。
请将模块自身所属的分类添加在文档中。本模块的子页面
local p = {}

function p.main(frame)
    local args = frame.args

    local text = args[1]

    if mw.ustring.sub(text, 1, 4) == 'ISBN' then
        return text
    end

    local ISBN = {}

    ISBN[#ISBN + 1] = 'ISBN '
    ISBN[#ISBN + 1] = mw.ustring.sub(text, 1, 3)
    ISBN[#ISBN + 1] = '-'
    ISBN[#ISBN + 1] = mw.ustring.sub(text, 4, 4)
    ISBN[#ISBN + 1] = '-'
    ISBN[#ISBN + 1] = mw.ustring.sub(text, 5, 8)
    ISBN[#ISBN + 1] = '-'
    ISBN[#ISBN + 1] = mw.ustring.sub(text, 9, 12)
    ISBN[#ISBN + 1] = '-'
    ISBN[#ISBN + 1] = mw.ustring.sub(text, 13)

    return table.concat(ISBN)
end

return p