'From Squeak6.0alpha of 10 May 2020 [latest update: #19666] on 11 May 2020 at 9:58:45 am'!
DynamicVariable subclass: #HtmlBaseURI
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Collections-Text'!
TextReadWriter subclass: #HtmlReadWriter
	instanceVariableNames: 'count offset runStack runArray string breakLines baseURI '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Collections-Text'!

!HtmlBaseURI class methodsFor: 'accessing' stamp: 'mt 5/11/2020 09:55'!
value: anObject during: aBlock

	^ super value: anObject asURI during: aBlock! !


!HtmlHelpTopic methodsFor: 'accessing' stamp: 'mt 5/11/2020 09:52'!
contents

	| start end |
	start := (self document findString: '<body').
	start := (self document findString: '>' startingAt: start) + 1.
	end := self document findString: '</body>' startingAt: start.
	
	start > end ifTrue: [^ self document].
	
	^ HtmlBaseURI value: self url during: [
		((self document copyFrom: start to: end - 1)
			copyReplaceAll: String cr with: '<br>') 
			asTextFromHtml]! !


!HtmlReadWriter methodsFor: 'accessing' stamp: 'mt 5/11/2020 09:46'!
baseURI

	^ baseURI ifNil: [HtmlBaseURI value]! !

!HtmlReadWriter methodsFor: 'accessing' stamp: 'mt 5/11/2020 09:40'!
baseURI: anURI

	baseURI := anURI asURI.! !

!HtmlReadWriter methodsFor: 'mapping' stamp: 'mt 5/11/2020 09:56'!
mapImgTag: aTag

	| result startIndex stopIndex attribute src form scaleFactor |
	result := OrderedCollection new.

	"<img src=""https://squeak.org/img/downloads/image.png"">"
	attribute := 'src'.
	startIndex := aTag findString: attribute.
	startIndex > 0 ifTrue: [
		startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
		startIndex > 0
			ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
			ifFalse: [
				"URLs without quotes..."
				startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
				stopIndex := aTag findString: '>' startingAt: startIndex+1].
		src := aTag copyFrom: startIndex+1 to: stopIndex-1.
		self baseURI ifNotNil: [:uri | src := (uri resolveRelativeURI: src) asString].
		form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
		(scaleFactor := RealEstateAgent scaleFactor) = 1.0
			ifFalse: [form := form scaledToSize: form extent * scaleFactor].
		result
			add: form asTextAnchor;
			add: (TextColor color: Color transparent)].
	^ result! !

TextReadWriter subclass: #HtmlReadWriter
	instanceVariableNames: 'count offset runStack runArray string breakLines baseURI'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Collections-Text'!

!HtmlBaseURI class reorganize!
('accessing' value:during:)
!

