[squeak-dev] The Inbox: Collections-eem.732.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Feb 8 18:55:53 UTC 2017
Eliot Miranda uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-eem.732.mcz
==================== Summary ====================
Name: Collections-eem.732
Author: eem
Time: 8 February 2017, 10:55:41.894202 am
UUID: c2c7f1c4-f586-4872-b2c7-6fb7f9cd6527
Ancestors: Collections-dtl.731
Modify HtmlReadWriter to enclose indented text within <pre></pre> to preserve formatting of, for example, code.
=============== Diff against Collections-dtl.731 ===============
Item was added:
+ ----- Method: HtmlReadWriter>>linesWithAttributesIn:do: (in category 'writing') -----
+ linesWithAttributesIn: aText do: aBlock
+ "Evauate aBlock with a string and the emphasis for that string, guaranteeing
+ that if the string contains a line break, it occurs at the end of the line."
+ aText runs withStartStopAndValueDo:
+ [:start :stop :attributes | | att idx startIdx |
+ startIdx := start.
+ [att := aText attributesAt: startIdx.
+ idx := aText string indexOf: Character cr from: startIdx to: stop ifAbsent: stop.
+ aBlock value: (aText string copyFrom: startIdx to: idx) value: att.
+ idx < stop]
+ whileTrue:
+ [startIdx := idx + 1]]!
Item was changed:
----- Method: HtmlReadWriter>>nextPutText: (in category 'accessing') -----
nextPutText: aText
+ | atStartOfLine inIndent cr |
+ atStartOfLine := true.
+ inIndent := false.
+ cr := Character cr.
+ self linesWithAttributesIn: aText do:
+ [:string :attributes | | indented |
+ atStartOfLine ifTrue:
+ [indented := string first == Character tab.
+ indented ~~ inIndent ifTrue:
+ [stream nextPutAll: (indented ifTrue: ['<pre>'] ifFalse: ['</pre>']).
+ inIndent := indented]].
+ attributes do: [:each | self writeStartTagFor: each].
+ inIndent
+ ifTrue: [self writePresentationContent: string]
+ ifFalse: [self writeContent: string].
+ attributes reverseDo: [:each | self writeEndTagFor: each].
+ atStartOfLine := string last == cr].
+ inIndent ifTrue:
+ [stream nextPutAll: '</pre>']!
-
- aText runs
- withStartStopAndValueDo: [:start :stop :attributes |
- | att str |
- att := aText attributesAt: start.
- str := aText string copyFrom: start to: stop.
-
- att do: [:each | self writeStartTagFor: each].
- self writeContent: str.
- att reverse do: [:each | self writeEndTagFor: each]]!
Item was added:
+ ----- Method: HtmlReadWriter>>writePresentationContent: (in category 'writing') -----
+ writePresentationContent: aString
+
+ aString do: [:char |
+ char = Character tab
+ ifTrue: [stream nextPutAll: ' ']
+ ifFalse: [(String htmlEntities keyAtValue: char ifAbsent: [])
+ ifNil: [stream nextPut: char]
+ ifNotNil: [:escapeSequence |
+ stream
+ nextPut: $&;
+ nextPutAll: escapeSequence;
+ nextPut: $;]]]!
Item was added:
+ ----- Method: SequenceableCollection>>indexOf:from:to:ifAbsent: (in category 'accessing') -----
+ indexOf: anElement from: start to: end ifAbsent: exceptionBlock
+ "Answer the index of the first occurence of anElement from start to stop
+ within the receiver. If the receiver does not contain anElement in the,
+ range answer the result of evaluating the argument, exceptionBlock."
+
+ start to: end do:
+ [:index |
+ (self at: index) = anElement ifTrue: [^index]].
+ ^exceptionBlock value!
More information about the Squeak-dev
mailing list
|