Module:Citation/CS1: Difference between revisions
sync to sandbox, make ISBN forgiving in a similar way to Special:BookSources, fix newline in italics
m>Dragons flight (fix isbn flag, add some spaces) |
m>Dragons flight (sync to sandbox, make ISBN forgiving in a similar way to Special:BookSources, fix newline in italics) |
||
Line 208: | Line 208: | ||
return false; | return false; | ||
end | end | ||
end | |||
-- Removes irrelevant text and dashes from ISBN number | |||
-- Similar to that used for Special:BookSources | |||
function cleanisbn( isbn_str ) | |||
return isbn_str:gsub( "[^-0-9X]", "" ); | |||
end | end | ||
-- Determines whether an ISBN string is valid | -- Determines whether an ISBN string is valid | ||
function checkisbn( isbn_str ) | function checkisbn( isbn_str ) | ||
isbn_str = isbn_str:gsub(" | isbn_str = cleanisbn( isbn_str ):gsub( "-", "" ); | ||
local len = isbn_str:len(); | local len = isbn_str:len(); | ||
Line 283: | Line 289: | ||
if str:sub(1,1) == "'" then str = "<span />" .. str; end | if str:sub(1,1) == "'" then str = "<span />" .. str; end | ||
if str:sub(-1,-1) == "'" then str = str .. "<span />"; end | if str:sub(-1,-1) == "'" then str = str .. "<span />"; end | ||
return str; | return str:gsub( '\n', ' ' ); | ||
end | end | ||
end | end | ||
Line 850: | Line 856: | ||
for k, v in pairs( ID_list ) do | for k, v in pairs( ID_list ) do | ||
if k == 'ISBN' then | |||
v = cleanisbn( v ); | |||
end | |||
if string.sub( cfg.id_handlers[k].COinS or "info", 1, 4 ) ~= 'info' then | if string.sub( cfg.id_handlers[k].COinS or "info", 1, 4 ) ~= 'info' then | ||
OCinSdata[ cfg.id_handlers[k].COinS ] = v; | OCinSdata[ cfg.id_handlers[k].COinS ] = v; |