词条 | Module:Librivox book |
释义 | local p = {} function p.book(frame) local pframe = frame:getParent() local args = pframe.args local title = nil -- display and search title (default: article name w/out dab) local dtitle = nil -- display title (default: title) local stitle = nil -- search title (default: title) local lname = nil -- last name local id = nil -- unsupported argument local author = nil -- author local tagline = "public domain audiobook at LibriVox" local urlhead = "https://librivox.org/search?" local italic = "''" id = trimArg(args.id) if id then error("Error in Template:" .. tname .. " - id argument not supported - please see documentation at Librivox author") end title = trimArg(args.title) if not title then title = mw.title.getCurrentTitle().text end dtitle = mw.ustring.gsub(title,'%s+%([^%(]-%)$', '') -- Remove the final disambig paren stitle = dtitle if trimArg(args.stitle) then stitle = trimArg(args.stitle) if not trimArg(args.title) then -- For when used outside main article space dtitle = stitle end end if trimArg(args.dtitle) then dtitle = trimArg(args.dtitle) italic = "" end author = trimArg(args.author) if not author then lname = "" else --- Split name into words, count words, set name to last word local N = mw.text.split(author, " ") local l, count = mw.ustring.gsub(author, "%S+", "") lname = N[count] end end function trimArg(arg) if arg == "" or arg == nil then return nil else return mw.text.trim(arg) end end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。