The Inbox: Collections-ct.944.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Collections-ct.944.mcz

commits-2
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.944.mcz

==================== Summary ====================

Name: Collections-ct.944
Author: ct
Time: 6 May 2021, 7:19:19.626252 pm
UUID: ff2ccbdf-62a6-9040-ba1a-5c7ae932a1c9
Ancestors: Collections-mt.943

Fixes a slip in HtmlReadWriter when encountering an empty CSS value.

Note that according to W3C, empty CSS values are not permitted, but let's not make our converter fail for such a trivial reason, in particular since I met such a tag in the wild. Also, the check already exists anyway. :-)

=============== Diff against Collections-mt.943 ===============

Item was changed:
  ----- 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: [
+ value := keyValue second.
  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!