Modul:LinkISBN: Unterschied zwischen den Versionen
(Wartung) |
(Wartung) |
||
Zeile 31: | Zeile 31: | ||
local comment = '', t | local comment = '', t | ||
m, comment = lb.extractComment( m ) | |||
m = | m = m:gsub( 'ISBN *', '' ):upper() -- x -> X | ||
t = '<span class="' .. li.class .. '" title="' .. li.special .. m | t = '<span class="' .. li.class .. '" title="' .. li.special .. m | ||
.. '">[[' .. li.special .. m .. '|' .. 'ISBN ' .. m .. ']]</span>' | .. '">[[' .. li.special .. m .. '|' .. 'ISBN ' .. m .. ']]</span>' | ||
if not noerror then | if not noerror then | ||
t = t .. ci._check_isbn( m, li.invalid .. ( demo and '' or li.invalidCat ) ) | |||
end | end | ||
if comment ~= '' then | if comment ~= '' then | ||
Zeile 55: | Zeile 46: | ||
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.noerror = yn( args.noerror | args.noerror = yn( args.noerror, false ) | ||
if args.isbn == '' then | if args.isbn == '' then | ||
return '' | return '' |
Version vom 9. Juli 2019, 06:08 Uhr
Die Dokumentation für dieses Modul kann unter Modul:LinkISBN/doc erstellt werden
-- documentation local LinkISBN = { suite = 'LinkISBN', serial = '2019-07-09', item = 65157187 } -- module variable, i18n local li = { invalid = ' <span class="error">Ungültige ISBN</span>', invalidCat = '[[Category:Seiten mit ISBN-Fehlern]]', special = 'Special:ISBN-Suche/', -- Special:BookSources -- patterns for delimiters except ',' delimiters = { ' and ', ' or ', ' und ', ' oder ', ';' }, -- CSS class class = 'wv-booksources' } -- module import local ci = require( 'Module:Check_isxn' ) local lb = require( 'Module:LinkBase' ) local yn = require( 'Module:Yesno' ) function li.linkISBN( m, noerror, demo ) m = mw.text.trim( m ) if m == '' then -- empty string return m end local comment = '', t m, comment = lb.extractComment( m ) m = m:gsub( 'ISBN *', '' ):upper() -- x -> X t = '<span class="' .. li.class .. '" title="' .. li.special .. m .. '">[[' .. li.special .. m .. '|' .. 'ISBN ' .. m .. ']]</span>' if not noerror then t = t .. ci._check_isbn( m, li.invalid .. ( demo and '' or li.invalidCat ) ) 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, false ) if args.isbn == '' then return '' end local ns = mw.title.getCurrentTitle().namespace local isDemo = ns == 10 or ns == 828 local result = '', i, s -- 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, isDemo ) if s ~= '' then result = ( result ~= '' and result .. ', ' or '' ) .. s end end return result end function li.linkISBNs( frame ) return li.linkISBNSet( frame:getParent().args ) end return li