Jump to content

Module:Cite taxon/utilities

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jts1882 (talk | contribs) at 07:50, 15 July 2020 (add basic functionality). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

p.format_species_list = function(frame)

  local list = frame.args[1]
  list = mw.text.trim( list )
  
  local names = mw.text.split( list, "\n", plain )
  local genus, species, authority
  local output = ""
  --for k, v in pairs( names ) do
  	 --genus, species, authority = string.gmatch( v, " " )
  local i = 1
  while names[i] do
  	 for genus, species, authority in string.gmatch(names[i], "(%S+) (%S+) (.+)" ) do 
  	 	output = output .. "\n*''[[" .. genus .. " " .. species .. "]]'' " 
  	 	        .. frame:expandTemplate{ title = 'small', args = { authority } } 
  	 end
  	 i=i+1
  end
  
  
  
  return output
	
end

return p