-- <pre>
--
-- implements {{Slugify}}
--
-- For module calls:
function slugify( str )
-- this probably misses some characters
-- it's also opinionated: there are different slugify methods you could use,
-- depending on what characters you want to remove/replace and how
return str
:gsub( '%-', ' ' ) -- replace hyphens with spaces
:gsub( '%p', '' ) -- strip all punctuation
:gsub( '%s+', '-' ) -- collapse spaces and replace with hyphens
:lower()
end
-- For wikitext calls:
function main( frame )
local args = frame:getParent().args
local str = args[ 1 ] or ''
return slugify( str )
end
return {
main = main,
slugify = slugify,
}
-- </pre>