Дакумэнтацыю да гэтага модуля можна стварыць у Модуль:Кніга librivox/Дакумэнтацыя

local p = {}
 
function p.book(frame)

  local pframe = frame:getParent()
  local args = pframe.args

  local tname = "Кніга librivox" -- назва шаблёну, які выклікае модуль. Зьмяніць пры перайменаваньні шаблёну.

  local title   = nil -- назва для вываду і пошуку (дапомна: назва артыкулу)
  local dtitle  = nil -- назва для вываду (дапомна: title)
  local stitle  = nil -- назва для пошуку (дапомна: title)
  local lname   = nil -- прозьвішча
  local author  = nil -- аўтар
  local tagline = "у вольным доступе на [[LibriVox]]"
  local urlhead = "https://librivox.org/search?"
  local italic   = "''"

  title = trimArg(args['назва'])
  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['пназва']) then
    stitle = trimArg(args['пназва'])
    if not trimArg(args['назва']) then                           -- For when used outside main article space
      dtitle = stitle
    end
  end
  if trimArg(args['вназва']) then
    dtitle = trimArg(args['вназва'])
    italic  = ""
  end

  local stitle = mw.ustring.gsub(stitle," ", "+")             -- replace "<space>" with "+"

  author = trimArg(args['аўтар'])
  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

  local url = "[[Файл:Speaker Icon.svg|15пкс|link=|alt=]] " .. "Аўдыёкніга [" .. 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 .. "]" .. " " .. tagline

  return url

end

function trimArg(arg)
  if arg == "" or arg == nil then
    return nil
  else
    return mw.text.trim(arg)
  end
end

return p