<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
<div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">It</span><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"> </span><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">has nothing to do with collections.</span></div><div><br></div><div>Why not? The target format, Text, is a Collection.<div><br></div><div>Best,</div><div>Marcel</div></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 20.04.2020 13:52:10 schrieb Levente Uzonyi <leves@caesar.elte.hu>:</p><div style="font-family:Arial,Helvetica,sans-serif">On Mon, 20 Apr 2020, Marcel Taeumel wrote:
<br>
<br>> > Still strange that such things are in Collections.
<br>>
<br>> There has been a discussion on this list about CollectionsExtras. Maybe we should follow up on that.
<br>
<br>An HTML to text converter wouldn't fit into CollectionsExtras either. It
<br>has nothing to do with collections.
<br>
<br>
<br>Levente
<br>
<br>>
<br>> Best,
<br>> Marcel
<br>>
<br>> Am 18.04.2020 15:29:14 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:
<br>>
<br>> Great idea!
<br>>
<br>>
<br>> > Still strange that such things are in Collections.
<br>>
<br>> __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
<br>> Von: Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Jakob Reschke <forums.jakob@resfarm.de>
<br>> Gesendet: Freitag, 17. April 2020 19:45:38
<br>> An: squeak-dev@lists.squeakfoundation.org
<br>> Betreff: Re: [squeak-dev] The Trunk: Collections-mt.886.mcz
<br>> Still strange that such things are in Collections.
<br>>
<br>> Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb <commits@source.squeak.org>:
<br>> >
<br>> > Marcel Taeumel uploaded a new version of Collections to project The Trunk:
<br>> > http://source.squeak.org/trunk/Collections-mt.886.mcz
<br>> >
<br>> > ==================== Summary ====================
<br>> >
<br>> > Name: Collections-mt.886
<br>> > Author: mt
<br>> > Time: 17 April 2020, 4:56:30.33186 pm
<br>> > UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
<br>> > Ancestors: Collections-eem.885
<br>> >
<br>> > To our HTML-to-Text converter, add support for <img></img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
<br>> >
<br>> > =============== Diff against Collections-eem.885 ===============
<br>> >
<br>> > Item was added:
<br>> > + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
<br>> > + httpGetImage: url
<br>> > + "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
<br>> > +
<br>> > + (url beginsWith: 'code://') ifTrue: [
<br>> > + "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
<br>> > + ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
<br>> > + ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
<br>> > +
<br>> > + ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
<br>> > + ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
<br>> > + response code = 200 ifFalse: [nil] ifTrue: [
<br>> > + [Form fromBinaryStream: response content asByteArray readStream]
<br>> > + ifError: [nil]]]]!
<br>> >
<br>> > Item was added:
<br>> > + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
<br>> > + mapImgTag: aTag
<br>> > +
<br>> > + | result startIndex stopIndex attribute src form |
<br>> > + result := OrderedCollection new.
<br>> > +
<br>> > + "<img https://squeak.org/img/downloads/image.png""=""></img>"
<br>> > + attribute := 'src'.
<br>> > + startIndex := aTag findString: attribute.
<br>> > + startIndex > 0 ifTrue: [
<br>> > + startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
<br>> > + startIndex > 0
<br>> > + ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
<br>> > + ifFalse: [
<br>> > + "URLs without quotes..."
<br>> > + startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
<br>> > + stopIndex := aTag findString: '>' startingAt: startIndex+1].
<br>> > + src := aTag copyFrom: startIndex+1 to: stopIndex-1.
<br>> > + form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
<br>> > + result
<br>> > + add: form asTextAnchor;
<br>> > + add: (TextColor color: Color transparent)].
<br>> > + ^ result!
<br>> >
<br>> > Item was changed:
<br>> > ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
<br>> > mapTagToAttribute: aTag
<br>> >
<br>> > aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
<br>> > aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
<br>> > aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
<br>> > aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
<br>> > aTag = '<code>' ifTrue: [^ self mapCodeTag].
<br>> > aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
<br>> > (#('<div'></div'><span'></span'><center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
<br>> > ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
<br>> > (aTag beginsWith: '<font') iftrue:="" [^="" self="" mapfonttag:="" atag].=""></font')><br>> > (aTag beginsWith: '<a') iftrue:="" [^="" self="" mapatag:="" atag].=""></a')><br>> > + (aTag beginsWith: '<img') iftrue:="" [^="" self="" mapimgtag:="" atag].=""></img')><br>> >
<br>> > "h1, h2, h3, ..."
<br>> > (aTag second = $h and: [aTag third isDigit])
<br>> > ifTrue: [^ {TextEmphasis bold}].
<br>> >
<br>> > ^ {}!
<br>> >
<br>> > Item was changed:
<br>> > ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
<br>> > processEmptyTag: aTag
<br>> >
<br>> > (aTag beginsWith: '<br') iftrue:="" [=""></br')><br>> > self addCharacter: Character cr.
<br>> > ^ self].
<br>> >
<br>> > + (aTag beginsWith: '<img') iftrue:[=""></img')><br>> > + ^ self processStartTag: aTag].
<br>> > +
<br>> > (self isTagIgnored: aTag)
<br>> > ifTrue: [^ self].
<br>> >
<br>> > "TODO... what?"!
<br>> >
<br>> > Item was added:
<br>> > + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
<br>> > + processEndTagEagerly: aTag
<br>> > + "Not all tags need an end tag. Simulate that here."
<br>> > +
<br>> > + (aTag beginsWith: '<img')></img')><br>> > + ifTrue: [^ self processEndTag: '<img></img>'].!
<br>> >
<br>> > Item was changed:
<br>> > ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
<br>> > processStartTag: aTag
<br>> >
<br>> > | index |
<br>> > (self isTagIgnored: aTag) ifTrue: [^ self].
<br>> >
<br>> > index := count - offset.
<br>> >
<br>> > aTag = '<br>' ifTrue: [
<br>> > self addCharacter: Character cr.
<br>> > ^ self].
<br>> > +
<br>> > (aTag beginsWith: '<img') iftrue:="" [=""></img')><br>> > + self addString: Character startOfHeader asString.
<br>> > + offset := offset + 1.
<br>> > + index := index - 1].
<br>> > - self addString: '[image]'.
<br>> > - ^ self].
<br>> >
<br>> > self processRunStackTop. "To add all attributes before the next tag adds some."
<br>> >
<br>> > "Copy attr list and add new attr."
<br>> > runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
<br>> > +
<br>> > + "For tags such as <img></img>, we should simulate the closing tag because there won't be any."
<br>> > + self processEndTagEagerly: aTag.!
<br>> > - !
<br>> >
<br>> >
<br>>
<br>>
<br>>
<br>><br></center></pre></code></s></u></i></b></commits@source.squeak.org></forums.jakob@resfarm.de></squeak-dev-bounces@lists.squeakfoundation.org></christoph.thiede@student.hpi.uni-potsdam.de></div></blockquote>
</div></body>