GrafoscopioUtils/repository/Grafoscopio-Utils/String.extension.st

52 lines
1.5 KiB
Smalltalk

Extension { #name : #String }
{ #category : #'*Grafoscopio-Utils' }
String >> accentedCharactersCorrection [
| modified corrections |
corrections := {
'ó' -> 'ó' . 'ú' -> 'ú' . 'ñ' -> 'ñ' .
'í' -> 'í' . 'á' -> 'á' . 'é' -> 'é' } asDictionary.
modified := self copy.
corrections keysAndValuesDo: [ :k :v |
modified := modified copyReplaceAll: k with: v
].
^ modified
]
{ #category : #'*Grafoscopio-Utils' }
String >> asCapitalizedPhrase [
"I convert phrases like 'THIS IS A PHRASE' into 'This is a Phrase'."
^ Character space join: (self substrings collect: [:each | each asLowercase capitalized ])
]
{ #category : #'*Grafoscopio-Utils' }
String >> asDashedLowercase [
"I convert phrases like 'This is a phrase' into 'this-is-a-phrase'."
^ '-' join: (self substrings collect: [:each | each asLowercase ])
]
{ #category : #'*Grafoscopio-Utils' }
String >> correctAccentedCharacters [
| output |
output := self
copyReplaceAll: 'ó' with: 'ó'.
output := output copyReplaceAll: 'á' with: 'á'.
output := output copyReplaceAll: 'é' with: 'é'.
output := output copyReplaceAll: 'í' with: 'í'.
output := output copyReplaceAll: 'ú' with: 'ú'.
output := output copyReplaceAll: 'ñ' with: 'ñ'.
output := output copyReplaceAll: '“' with: '“'.
output := output copyReplaceAll: '”' with: '”'.
^ output
]
{ #category : #'*Grafoscopio-Utils' }
String >> isOrgModeHeader [
^ self beginsWithAnyOf: #('* ' '** ' '*** ' '**** ' '***** ' '***** ')
]