Module:no-diacritics
Jump to navigation
Jump to search
- The following documentation is located at Module:no-diacritics/documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local acute_or_grave = "[" .. mw.ustring.char(0x301) .. mw.ustring.char(0x300) .. "]"
local accentedLetters = 'áàéèóò'
-- Decompose, remove acutes and graves, return first return value.
-- Beware: this decomposes Å to A + ◌̊.
function export.removeAccents(term)
return term:find("[\128-\255]") and mw.ustring.gsub(mw.ustring.toNFD(term), acute_or_grave, "")
or term
end
function export.hasAccents(term)
regex = '[' .. accentedLetters .. ']'
return mw.ustring.match(term, regex) ~= nil
end
return export