Zum Inhalt springen

Modul:LinkISBN: Unterschied zwischen den Versionen

code check
K (args.noerror -> args.ignoreError)
(code check)
Zeile 2: Zeile 2:
local LinkISBN = {
local LinkISBN = {
suite  = 'LinkISBN',
suite  = 'LinkISBN',
serial = '2020-03-26',
serial = '2020-05-16',
item  = 65157187
item  = 65157187
}
}
Zeile 19: Zeile 19:
function li._linkISBN( m, ignoreError, demo )
function li._linkISBN( m, ignoreError, demo )
m = mw.text.trim( m )
m = mw.text.trim( m )
if m == '' then -- empty string
if m == '' then
return m
return m
end
end


local comment = '', t
local comment = ''
m, comment = lb.extractComment( m )
m, comment = lb.extractComment( m )


m = m:gsub( 'ISBN *', '' ):upper() -- x -> X
m = m:gsub( 'ISBN *', '' ):upper() -- x -> X
t = '<span class="' .. li.classes.booksources .. '" title="'
local t = '<span class="' .. li.classes.booksources .. '" title="'
.. li.categories.special .. m .. '">[[' .. li.categories.special
.. li.categories.special .. m .. '">[[' .. li.categories.special
.. m .. '|' .. 'ISBN ' .. m .. ']]</span>'
.. m .. '|' .. 'ISBN ' .. m .. ']]</span>'
Zeile 42: Zeile 42:
-- link a list of several ISBNs
-- link a list of several ISBNs
function li._linkISBNSet( args )
function li._linkISBNSet( args )
args.isbn   = args.isbn or args[ 1 ] or ''
args.isbn = args.isbn or args[ 1 ] or ''
args.ignoreError = args.ignoreError or args.noerror
args.ignoreError = yn( args.ignoreError, false )
if args.isbn == '' then
if args.isbn == '' then
return ''
return ''
end
end
args.ignoreError = yn( args.ignoreError or args.noerror, false )


local ns    = mw.title.getCurrentTitle().namespace
local ns    = mw.title.getCurrentTitle().namespace
local isDemo = ns == 10 or ns == 828
local isDemo = ns == 10 or ns == 828
local result = '', i, s
-- split separate ISBNs
-- split separate ISBNs
local items = lb.splitItems( args.isbn, li.delimiters )
local items = lb.splitItems( args.isbn, li.delimiters )
-- analyse ISBNs
-- analyse ISBNs
for i = 1, #items, 1 do
local result = ''
s = li._linkISBN( items[ i ], args.ignoreError, isDemo )
local s
for i, item in ipairs( items ) do
s = li._linkISBN( item, args.ignoreError, isDemo )
if s ~= '' then
if s ~= '' then
result = ( result ~= '' and result .. ', ' or '' ) .. s
result = ( result ~= '' and result .. ', ' or '' ) .. s
Anonymer Benutzer