local p = local plain = require("Module:Plain text")._mainlocal isInLead = require("Module:Is_infobox_in_lead")._mainlocal getArgs = require("Module:Arguments").getArgsfunction p.shortdesc(text, frame) return frame:expandTemplate endfunction p.firstToUpper(str) return (str:gsub("^%l", string.upper))endfunction p.main(frame) if (isInLead("[Ii]nfobox [Bb]ook")) then local args = getArgs(frame,) local short_description = plain(args.short_description) local output = "" -- add year local published = plain(args.pub_date or args.release_date or args.published) if published then if not (string.find(published, "–")) and string.len(published) < 40 then if string.match(published, "%d%d%d%d") then output = string.match(published, "%d%d%d%d") .. " " end end end local type = "literary work" local specificfound = false local genres = -- looping through the "genre" attribute of the infobox local i = 1 if args.genre then local given = string.lower(plain(args.genre)) while (i <= #genres and not (specificfound)) do if string.find(given, genres[i], 1, true) then specificfound = true type = genres[i] end i = i + 1 end end if not (specificfound) then local content = mw.title.getCurrentTitle:getContent local start = string.find(content, "" .. mw.title.getCurrentTitle.text:gsub("%s%([^)]*%)", "") .. "", 1, true) local fin = string.find(content, "
"dictionary" or type
"literary work" then return "Too vague" else return p.firstToUpper(output) end else return "N/A" endend
return p