Modul:LinkISBN
Die Dokumentation für dieses Modul kann unter Modul:LinkISBN/doc erstellt werden
-- I18n
local li = {
invalid = ' <span class="error">Ungültige ISBN</span>',
invalidCat = '[[Kategorie:Seiten mit ISBN-Fehlern]]',
special = 'Spezial:ISBN-Suche/', -- Special:BookSources
-- patterns for delimiters except ','
delimiters = { ' and ', ' or ', ' und ', ' oder ', ';' },
-- CSS class
class = 'wv-booksources'
}
local ci = require( 'Modul:Check_isxn' )
local lb = require( 'Module:LinkBase' )
local yn = require( 'Modul:Yesno' )
function li.linkISBN( m, noerror, demo )
local mm = mw.text.trim( m )
if mm == '' then return mm end -- empty string
local comment = ''
local t = mw.ustring.gsub( mm, '(.*)(%(.*%))$', '%2' )
if t ~= mm then
comment = t
mm = mw.ustring.gsub( mw.ustring.gsub( mm, '(.*)(%(.*%))$', '%1' ), '( +)$', '' )
end
mm = mw.ustring.gsub( mm, 'ISBN ', '' )
t = '<span class="' .. li.class .. '" title="' .. li.special .. mm
.. '">[[' .. li.special .. mm .. '|' .. 'ISBN ' .. mm .. ']]</span>'
if not noerror then
if demo then
t = t .. ci._check_isbn( mm, li.invalid )
else
t = t .. ci._check_isbn( mm, li.invalid .. li.invalidCat )
end
end
if comment ~= '' then t = t .. ' ' .. comment end
return t
end
function li.linkISBNSet( args )
args.isbn = args.isbn or args[1] or ''
args.noerror = yn( args.noerror or '', false )
args.demo = yn( args.demo or '', false )
local i, s
local result = ''
if args.isbn ~= '' then
-- split separate ISBNs
local items = lb.splitItems( args.isbn, li.delimiters )
-- analyse ISBNs
for i = 1, #items, 1 do
s = li.linkISBN( items[ i ], args.noerror, args.demo )
if s ~= '' then
if result == '' then result = s
else result = result .. ', ' .. s
end
end
end
end
return result
end
function li.linkISBNs( frame )
local args = frame.args
return li.linkISBNSet( args )
end
return li