This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
localp={}functionp.book(frame)localpframe=frame:getParent()localargs=pframe.argslocaltname="Librivox book"-- name of calling template. Change if template rename.localtitle=nil-- display and search titlelocaldtitle=nil-- display title (default: title)localstitle=nil-- search title (default: title)locallname=nil-- last namelocalid=nil-- unsupported argumentlocalauthor=nil-- authorlocaltagline="public domain audiobook at [[LibriVox]]"localurlhead="https://librivox.org/search?"localitalic="''"id=trimArg(args.id)ifidthenerror("Error in Template:"..tname.." - id argument not supported - please see documentation at [[Template:Librivox author]]")endtitle=trimArg(args.title)ifnottitlethentitle=mw.title.getCurrentTitle().text:gsub('%s+%([^%(]-%)$','')-- Current page name without the final parenthesesdtitle=titlestitle=dtitleelsedtitle=titlestitle=dtitleendiftrimArg(args.stitle)thenstitle=trimArg(args.stitle)ifnottrimArg(args.title)thendtitle=stitleendendiftrimArg(args.dtitle)thendtitle=trimArg(args.dtitle)italic=""endlocaldtitle=mw.ustring.gsub(dtitle,"%s+%([^%(]-%)$","")-- remove disambiguation () localstitle=mw.ustring.gsub(stitle,"%s+%([^%(]-%)$","")localstitle=mw.ustring.gsub(stitle," ","+")-- replace "<space>" with "+"author=trimArg(args.author)ifnotauthorthenlname=""else--- Split name into words, count words, set name to last wordlocalN=mw.text.split(author," ")locall,count=mw.ustring.gsub(author,"%S+","")lname=N[count]endlocalurl="[[Image:Speaker Icon.svg|20px]] ".."["..urlhead.."title="..stitle.."&author="..lname.."&reader=&keywords=&genre_id=0&status=all&project_type=either&recorded_language=&sort_order=catalog_date&search_page=1&search_form=advanced".." "..italic..dtitle..italic.."]".." "..taglinereturnurlendfunctiontrimArg(arg)ifarg==""orarg==nilthenreturnnilelsereturnmw.text.trim(arg)endendreturnp