[squeak-dev] The Inbox: Collections-fn.740.mcz

H. Hirzel hannes.hirzel at gmail.com
Tue Mar 7 12:32:14 UTC 2017


It was stated that the class should be moved but no proposal yet to
which category....


Start of thread
http://lists.squeakfoundation.org/pipermail/squeak-dev/2017-February/193065.html

Question here:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2017-February/193091.html

"and what is HtmlReadWriter  and TextWriter doing in Collections anyway?

If it were in a text generation package I'd have a chance of maintaining my
fork while I wait for a functional system that easily supports generating
blog posts.

Right now I have little chance of affording to maintain a fork given
that this is in Collections of all places :-(
"


--Hannes

On 3/7/17, Fabio Niephaus <lists at fniephaus.com> wrote:
> I'm afraid I didn't see the discussion and also I'm not a core dev.
> But please feel free to recategorize the HtmlReadWriter. :)
>
> Fabio
>
> --
>
> On Tue, Mar 7, 2017 at 11:34 AM H. Hirzel <hannes.hirzel at gmail.com> wrote:
>
>> It was discussed earlier that 'HtmlReadWriter' is not well placed in
>> the 'Collections' category.
>>
>> It should be moved to a different category.
>>
>> Or into a new one.
>>
>> --Hannes
>>
>>
>> On Tue, 7 Mar 2017 09:49:56 0000, commits at source.squeak.org
>> <commits at source.squeak.org> wrote:
>> > Fabio Niephaus uploaded a new version of Collections to project The
>> Inbox:
>> > http://source.squeak.org/inbox/Collections-fn.740.mcz
>> >
>> > ==================== Summary ====================
>> >
>> > Name: Collections-fn.740
>> > Author: fn
>> > Time: 7 March 2017, 10:49:27.466847 am
>> > UUID: 1133e89d-10ca-4fa1-a98c-c1082fd360e6
>> > Ancestors: Collections-ul.739, Collections-fn.712
>> >
>> > HtmlReadWriter: Add support for style attributes in div and span
>> containers
>> > and numberic HTML entities.
>> >
>> > =============== Diff against Collections-ul.739 ===============
>> >
>> > Item was added:
>> > + ----- Method: HtmlReadWriter>>mapContainerTag: (in category
>> > 'mapping')
>> > -----
>> > + mapContainerTag: aTag
>> > +
>> > +     | result styleStart styleEnd styleAttributes |
>> > +     result := OrderedCollection new.
>> > +     styleStart := (aTag findString: 'style="' ) + 7.
>> > +     styleStart <= 7 ifTrue: [^#()].
>> > +     styleEnd := (aTag findString: '"' startingAt: styleStart) - 1.
>> > +     styleAttributes := (aTag copyFrom: styleStart to: styleEnd)
>> subStrings:
>> > ';'.
>> > +     styleAttributes do: [:ea | |keyValue key value|
>> > +             keyValue := (ea subStrings: ':') collect: [:s | s
>> withBlanksTrimmed].
>> > +             key := keyValue first asLowercase.
>> > +             value := keyValue second.
>> > +             keyValue size = 2 ifTrue: [
>> > +                     key = 'color' ifTrue: [result add: (TextColor
>> color: (Color fromString:
>> > value))].
>> > +                     (key beginsWith: 'font') ifTrue: [
>> > +                             (value includesSubstring: 'bold')
>> > +                                     ifTrue: [result add: TextEmphasis
>> bold].
>> > +                             (value includesSubstring: 'italic')
>> > +                                     ifTrue: [result add: TextEmphasis
>> italic]]]].
>> > +     ^ result!
>> >
>> > Item was changed:
>> >   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category
>> 'mapping')
>> > -----
>> >   mapTagToAttribute: aTag
>> >
>> >       aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
>> >       aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
>> >       aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
>> >       aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
>> >       aTag = '<code>' ifTrue: [^ self mapCodeTag].
>> >       aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
>> > +     (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag
>> > beginsWith:
>> ea])
>> > +             ifTrue: [^(self mapAlignmentTag: aTag) union: (self
>> mapContainerTag:
>> > aTag)].
>> > -     (aTag = '<center>' or: [aTag beginsWith: '<div'])
>> > -             ifTrue: [^ self mapAlignmentTag: aTag].
>> >       (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
>> >       (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
>> >
>> >       "h1, h2, h3, ..."
>> >       (aTag second = $h and: [aTag third isDigit])
>> >               ifTrue: [^ {TextEmphasis bold}].
>> >
>> >       ^ {}!
>> >
>> > Item was changed:
>> >   ----- Method: HtmlReadWriter>>processHtmlEscape: (in category
>> 'reading')
>> > -----
>> >   processHtmlEscape: aString
>> > +     | escapeSequence |
>> > +     escapeSequence := aString copyFrom: 2 to: aString size - 1.
>> > +     escapeSequence first = $# ifTrue: [^ self
>> > processHtmlEscapeNumber:
>> > escapeSequence allButFirst].
>> > -
>> >       (String htmlEntities at: (aString copyFrom: 2 to: aString size -
>> > 1)
>> > ifAbsent: [])
>> >               ifNotNil: [:char |
>> >                       string add: char.
>> >                       count := count + 1].!
>> >
>> > Item was added:
>> > + ----- Method: HtmlReadWriter>>processHtmlEscapeNumber: (in category
>> > 'reading') -----
>> > + processHtmlEscapeNumber: aString
>> > +     | number |
>> > +     number := aString first = $x
>> > +             ifTrue: [ '16r', aString allButFirst ]
>> > +             ifFalse: [ aString ].
>> > +     string add: number asNumber asCharacter!
>> >
>> >
>> >
>>
>>
>


More information about the Squeak-dev mailing list