From c5ebe99e340bc95f2da90a33a1076d708bf66233 Mon Sep 17 00:00:00 2001 From: nestorsire Date: Mon, 21 Nov 2022 14:19:12 -0500 Subject: [PATCH] Improving accented characters sanitation. --- src/MiniDocs/String.extension.st | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/MiniDocs/String.extension.st b/src/MiniDocs/String.extension.st index 23de2db..87fe274 100644 --- a/src/MiniDocs/String.extension.st +++ b/src/MiniDocs/String.extension.st @@ -19,3 +19,16 @@ String >> asDashedLowercase [ ^ '-' join: (self substrings collect: [:each | each asLowercase ]) ] + +{ #category : #'*MiniDocs' } +String >> romanizeAccents [ + | modified corrections | + corrections := { + 'ó' -> 'o' . 'ú' -> 'u' . 'ñ' -> 'n' . + 'í' -> 'i' . 'á' -> 'a' . 'é' -> 'e' } asDictionary. + modified := self copy. + corrections keysAndValuesDo: [ :k :v | + modified := modified copyReplaceAll: k with: v + ]. + ^ modified +]