Class { #name : 'PPCommonMarkUtils', #superclass : 'Object', #classInstVars : [ 'Instance' ], #category : 'PetitMarkdown-Parser' } { #category : 'as yet unclassified' } PPCommonMarkUtils class >> instance [ Instance isNil ifTrue: [ Instance := PPCommonMarkUtils new ]. ^ Instance ] { #category : 'as yet unclassified' } PPCommonMarkUtils >> decodeEntities: string [ | retval | retval := string. retval := retval copyReplaceAll: 'ö' with: 'รถ'. retval := retval copyReplaceAll: '&' with: '&'. retval := retval copyReplaceAll: '"' with: '"'. ^ retval ] { #category : 'as yet unclassified' } PPCommonMarkUtils >> encodeEntities: string [ | retval | retval := string. retval := retval copyReplaceAll: '&' with: '&'. retval := retval copyReplaceAll: '"' with: '"'. retval := retval copyReplaceAll: '>' with: '>'. retval := retval copyReplaceAll: '<' with: '<'. ^ retval ] { #category : 'as yet unclassified' } PPCommonMarkUtils >> escape: string [ | retval regex | retval := string. retval := retval copyReplaceAll: '\\' with: '\'. "Remove backlashes, \! -> !" regex := '\\[!#$%''()*+,-./:;=?@^_`{|}~]' asRegex. retval := regex copy: retval translatingMatchesUsing: [ :match | match second asString ]. retval := retval copyReplaceAll: '\"' with: '"'. retval := retval copyReplaceAll: '\[' with: '['. retval := retval copyReplaceAll: '\]' with: ']'. retval := retval copyReplaceAll: '\\' with: '\'. ^ retval ] { #category : 'as yet unclassified' } PPCommonMarkUtils >> escapeUrl: string [ | retval | retval := string. retval := retval copyReplaceAll: ' ' with: '%20'. retval := retval copyReplaceAll: '"' with: '%22'. retval := retval copyReplaceAll: '\' with: '%5C'. retval := retval copyReplaceAll: '[' with: '%5B'. retval := retval copyReplaceAll: '`' with: '%60'. retval := retval copyReplaceAll: 'ä' with: '%C3%A4'. retval := retval copyReplaceAll: 'ö' with: '%C3%B6'. ^ retval ]