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 08:42, 15 July 2020 (don't expand small template (for subst)). 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] or frame:getParents().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 
  	 	table.insert ( output , "\n*''[[" .. genus .. " " .. species .. "]]'' " 
  	 	--      				 .. frame:expandTemplate{ title = 'small', args = { authority } }  --expand template
  	 	    					 .. "{{small|" .. authority .."}}"                                    -- don't expand template
  	 	        )
  	 end
  	 i=i+1
  end
  
  
  
  return table.concat(output)
	
end

return p