Module:columns/auto/sandbox

Hello, you have come here looking for the meaning of the word Module:columns/auto/sandbox. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:columns/auto/sandbox, but we will also tell you about its etymology, its characteristics and you will know how to say Module:columns/auto/sandbox in singular and plural. Everything you need to know about the word Module:columns/auto/sandbox you have here. The definition of the word Module:columns/auto/sandbox will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:columns/auto/sandbox, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}
local m_links = require("Module:links")

function export.extract_lengths(text)
	local lengths = {}
	local items = mw.text.decode(m_links.remove_links(text):gsub("<.->", "")):gmatch("\n%* (+)")
	for i in items do
		table.insert(lengths, #i)
	end
	return lengths
end

function export.decide_number_of_columns(lang, number_of_items, lengths)
	local max_length = math.max(unpack(lengths))
	local avg_length = 0
	for _, i in ipairs(lengths) do avg_length = avg_length + i/#lengths end
	local l = (avg_length + max_length)/2
	
	if l <= 10 then
		return 5
	elseif l <= 20 then
		return 4
	elseif l <= 30 then
		return 3
	elseif l <= 40 then
		return 2
	else
		return 1
	end
end

function export.display_from(column_args, list_args)
	local m_table = require("Module:table")
	column_args = m_table.shallowcopy(column_args)
	local lang = require("Module:languages").getByCode(mw.text.trim(list_args), 1)
	column_args = 1
	local output = require("Module:columns").display_from(column_args, list_args)
	local lengths = export.extract_lengths(output)
	local n_columns = export.decide_number_of_columns(lang, m_table.length(list_args), export.extract_lengths(output))
	output = output:gsub('data%-column%-count="1"', 'data-column-count="' .. n_columns .. '"')
	return output
end

function export.display(frame)
	return export.display_from(frame.args, frame:getParent().args)
end

return export