>Dear Squeakers, >I tried to parse an HTML file like this in a trunk image and ran into a MNU: >FileStream fileNamed: ’some.html’ do: [:stream | HtmlParser parse: stream] >In HtmlText>>#initialize the message #replaceHtmlCharRefs is sent. I suppose this method was once the image. Otherwise HtmlPar>ser would never have worked. How can I find out, when it got lost? How would you do it? >Cheers, >Bernhard Go to the files archive and start opening old images to find what was removed. Your method is in a 3.2 image. I have old images lying around on my desktops and I cannot get off the couch right now, so I thought I’d look for it. Googling your selector “replaceHtmlCharRefs” would show that Steph had the same problem in 2009. Chris String>>#replaceHtmlCharRefs | pos ampIndex scIndex special specialValue outString outPos newOutPos | outString _ String new: self size. outPos _ 0. pos _ 1. [ pos <= self size ] whileTrue: [ "read up to the next ampersand" ampIndex _ self indexOf: $& startingAt: pos ifAbsent: [0]. ampIndex = 0 ifTrue: [ pos = 1 ifTrue: [ ^self ] ifFalse: [ ampIndex _ self size+1 ] ]. newOutPos _ outPos + ampIndex - pos. outString replaceFrom: outPos + 1 to: newOutPos with: self startingAt: pos. outPos _ newOutPos. pos _ ampIndex. ampIndex <= self size ifTrue: [ "find the $;" scIndex _ self indexOf: $; startingAt: ampIndex ifAbsent: [ self size + 1 ]. special _ self copyFrom: ampIndex+1 to: scIndex-1. specialValue _ HtmlEntity valueOfHtmlEntity: special. specialValue ifNil: [ "not a recognized entity. wite it back" scIndex > self size ifTrue: [ scIndex _ self size ]. newOutPos _ outPos + scIndex - ampIndex + 1. outString replaceFrom: outPos+1 to: newOutPos with: self startingAt: ampIndex. outPos _ newOutPos.] ifNotNil: [ outPos _ outPos + 1. outString at: outPos put: specialValue.]. pos _ scIndex + 1. ]. ]. ^outString copyFrom: 1 to: outPos |
Hi Chris,
Thanks for the missing method and the tip regarding the old images. Cheers, Bernhard > Am 22.10.2017 um 19:33 schrieb Chris Cunnington <[hidden email]>: > > >Dear Squeakers, > > >I tried to parse an HTML file like this in a trunk image and ran into a MNU: > >FileStream fileNamed: ’some.html’ do: [:stream | HtmlParser parse: stream] > > >In HtmlText>>#initialize the message #replaceHtmlCharRefs is sent. I suppose this method was once the image. Otherwise HtmlPar>ser would never have worked. How can I find out, when it got lost? How would you do it? > > >Cheers, > >Bernhard > > Go to the files archive and start opening old images to find what was removed. Your method is in a 3.2 image. > I have old images lying around on my desktops and I cannot get off the couch right now, so I thought I’d look for it. > Googling your selector “replaceHtmlCharRefs” would show that Steph had the same problem in 2009. > > Chris > > > String>>#replaceHtmlCharRefs > > | pos ampIndex scIndex special specialValue outString outPos newOutPos | > > outString _ String new: self size. > outPos _ 0. > > pos _ 1. > > [ pos <= self size ] whileTrue: [ > "read up to the next ampersand" > ampIndex _ self indexOf: $& startingAt: pos ifAbsent: [0]. > > ampIndex = 0 ifTrue: [ > pos = 1 ifTrue: [ ^self ] ifFalse: [ ampIndex _ self size+1 ] ]. > > newOutPos _ outPos + ampIndex - pos. > outString > replaceFrom: outPos + 1 > to: newOutPos > with: self > startingAt: pos. > outPos _ newOutPos. > pos _ ampIndex. > > ampIndex <= self size ifTrue: [ > "find the $;" > scIndex _ self indexOf: $; startingAt: ampIndex ifAbsent: [ self size + 1 ]. > > special _ self copyFrom: ampIndex+1 to: scIndex-1. > specialValue _ HtmlEntity valueOfHtmlEntity: special. > > specialValue > ifNil: [ > "not a recognized entity. wite it back" > scIndex > self size ifTrue: [ scIndex _ self size ]. > > newOutPos _ outPos + scIndex - ampIndex + 1. > outString > replaceFrom: outPos+1 > to: newOutPos > with: self > startingAt: ampIndex. > outPos _ newOutPos.] > ifNotNil: [ > outPos _ outPos + 1. > outString at: outPos put: specialValue.]. > > pos _ scIndex + 1. ]. ]. > > > ^outString copyFrom: 1 to: outPos > |
Free forum by Nabble | Edit this page |