Модуль:ISBN
Перейти к навигации
Перейти к поиску
ISBN
Аргумент | Результат |
---|---|
5306001572 | ISBN 5306001572 |
5-306-00157-2 | ISBN 5-306-00157-2 |
5—306—00157—2 | ISBN 5—306—00157—2 |
5 306 00157 2 | ISBN 5 306 00157 2 |
5 306 00157 2 | ISBN 5 306 00157 2 |
ISBN 5306001572 | ISBN 5306001572 |
ISBN 5306001572, 5306001572-123 | ISBN 5306001572, 5306001572-123 |
ISBN 5306001572, 5306001583 | ISBN 5306001572, 5306001583 |
ISSN
Аргумент | Результат |
---|---|
00280836 | ISSN 00280836 |
0028-0836 | ISSN 0028-0836 |
0028—0836 | ISSN 0028—0836 |
0028 0836 | ISSN 0028 0836 |
0028 0836 | ISSN 0028 0836 |
ISSN 0028-0836, 0028-0825 | ISSN 0028-0836, 0028-0825 |
ISSN 0028-0836, 0028-0825 | ISSN 0028-0836, 0028-0825 |
local re = require "Module:Re"
local common = [==[
control <- digit / x
digit <- sep %d
x <- sep [xX] -> 'X'
space <- %s / ' '
hyphen <- '➖' / '−' / '-'/ '֊'/ '‐'/ '‑'/ '‒'/ '–'/ '—'/ '―'/ '⸺'/ '⸻'/ '﹘'/ '﹣'/ '-'
sep <- ( hyphen / space )? -> ''
listsep <- [,;] %s*
]==]
local function isbn (str, prefix, infix, suffix, property)
local format = re.compile ([==[
isbns <- {~ isbn (listsep isbn)* ~}
isbn <- ( prefix space* )? -> '' {~ ( isbn13 / isbn10 ) ~} -> ']==] .. prefix .. '%1' .. infix .. '%0' .. suffix
.. (property ~= '' and "{{#set:" .. property .. " = %1}}" or "") .. "'"
.. [==[
prefix <- 'ISBN' / 'isbn'
isbn13 <- digit^13
isbn10 <- digit^9 control
]==] .. common)
local markedup = format:match (str)
return markedup and '[[:ISBN]] ' .. markedup or ''
end -- function local isbn (str, prefix, infix, suffix, property)
local function issn (str, prefix, infix, suffix, property)
local format = re.compile ([==[
issns <- {~ issn (listsep issn)* ~}
issn <- ( prefix space* )? -> '' {~ issn8 ~} -> ']==] .. prefix .. '%1' .. infix .. '%0' .. suffix
.. (property ~= '' and "{{#set:" .. property .. " = %1}}" or "") .. "'"
.. [==[
prefix <- 'ISSN' / 'issn'
issn8 <- digit^8
]==] .. common)
local markedup = format:match (str)
return markedup and '[[:ISSN]] ' .. markedup or ''
end -- local function issn (str, prefix, infix, suffix, property)
local function wrap (func, default_prefix, default_infix, default_suffix)
return function (frame)
local args = mw.clone (frame.args)
local prefix = args.prefix or default_prefix
local infix = args.infix or default_infix
local suffix = args.suffix or default_suffix
args.prefix, args.infix, args.suffix = nil, nil, nil
local property = args.property or ''
args.property = nil
return frame:preprocess (func (table.concat (args, ', '), prefix, infix, suffix, property))
end -- return function (frame)
end -- local function wrap (func, default_prefix, default_infix, default_suffix)
return {
isbn = wrap (isbn, '[[Служебная:Источники книг/', '|', ']]')
, issn = wrap (issn, '[https://www.worldcat.org/search?q=', ' ', ']')
}