Module:Format for sorting

Description
Test using main:

hallo hallo d d hello this is 45567 ff

test using textString

series 45.567.1 ? = Scriptfout: de functie "textString" bestaat niet.

Roman numeral

Scriptfout: de functie "textString" bestaat niet.

Scriptfout: de functie "textString" bestaat niet.



--[[
-- {{#invoke:Strip title for sorting|main|...}}
]]--

local mDiacritics = require('Module:Diacritics')

local p = {}

local function removePunctuation( str )
	local str = str
	str = string.gsub( str,  "%-?[%p%.]+", "" )
	local addchars ={  "‘", "’", "“", "”" }
	for i, v in ipairs( addchars ) do
    	str = string.gsub(str, v, "")
	end
	if str == nil then
		error(" No string received. " )
	else
		return str
	end
end

local function removeDiacritics( str )
	str = mDiacritics.strip_diacrits( str )
	return str
end

function p.main( frame )
	local str = ""
	str = mw.text.unstrip(frame.args[1])
	str = removeDiacritics( str )
	str = string.lower( str )
	str = removePunctuation( str )
	if str == nil then
		error("...")
	else
		return str
	end
end

return p