<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        <span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 16px">> </span><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">Still strange that such things are in Collections.</span><br><div><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt"><br></span></div><div><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">There has been a discussion on this list about CollectionsExtras. Maybe we should follow up on that.</span></div><div><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt"><br></span></div><div><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">Best,</span></div><div><span style="font-family: Calibri, Arial, Helvetica, sans-serif;font-size: 12pt">Marcel</span></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 18.04.2020 15:29:14 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style="font-family:Arial,Helvetica,sans-serif">


<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif">
<p>Great idea!</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: rgb(0,0,0);font-family: Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: ;margin: 0">
<div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">
<div class="x__rp_U4 x_ms-font-weight-regular x_ms-font-color-neutralDark x_rpHighlightAllClass x_rpHighlightBodyClass" id="x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="x_divtagdefaultwrapper"><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="x_Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont"></font></div>
</div>
</span></div>
</div>
</div>
</div>
<div class="x__rp_T4" id="x_Item.MessagePartBody"><br>
</div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">> <span style="font-size: 12pt">Still strange that such things are in Collections.</span>
<div><br>
</div>
</div>
</div>
<div><span style="font-size: 10pt;color: #808080"></span></div>
</div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Jakob Reschke <forums.jakob@resfarm.de><br>
<b>Gesendet:</b> Freitag, 17. April 2020 19:45:38<br>
<b>An:</b> squeak-dev@lists.squeakfoundation.org<br>
<b>Betreff:</b> Re: [squeak-dev] The Trunk: Collections-mt.886.mcz</span>
<div> </div>
</div>
</div>
<span style="font-size: 10pt"><span style="font-size: 10pt">
<div class="PlainText">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>
> <a href="http://source.squeak.org/trunk/Collections-mt.886.mcz">http://source.squeak.org/trunk/Collections-mt.886.mcz</a><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> 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 src=""<a href="https://squeak.org/img/downloads/image.png">https://squeak.org/img/downloads/image.png</a>"">"<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' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])<br>
>                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].<br>
>         (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].<br>
>         (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].<br>
> +       (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].<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>
>                 self addCharacter: Character cr.<br>
>                 ^ self].<br>
><br>
> +       (aTag beginsWith: '<img') ifTrue:[<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')<br>
> +               ifTrue: [^ self processEndTag: '</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: [<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>, we should simulate the closing tag because there won't be any."<br>
> +       self processEndTagEagerly: aTag.!<br>
> -       !<br>
><br>
><br>
<br>
<br>
</div>
</span></span>
</div></blockquote>
                                        </div></body>