[Pkg] The Trunk: Collections-fn.740.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 10 19:27:30 UTC 2017


Tobias Pape uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/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 Packages mailing list