<div dir="ltr">Hi All,<div><br></div><div> I'd really like this to be in trunk. I've just written a blog post in a Workspace using this code (<a href="http://www.mirandabanda.org/cogblog/2017/02/07/smalltalk-scanning-and-shcontrol-structures/">http://www.mirandabanda.org/cogblog/2017/02/07/smalltalk-scanning-and-shcontrol-structures/</a>) and it turns creating a blog post into a simple copyHtml paste operation from a workspace to (in my case) WordPress. So any reviewers?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 8, 2017 at 10:55 AM, <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Eliot Miranda uploaded a new version of Collections to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-eem.732.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/<wbr>inbox/Collections-eem.732.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-eem.732<br>
Author: eem<br>
Time: 8 February 2017, 10:55:41.894202 am<br>
UUID: c2c7f1c4-f586-4872-b2c7-<wbr>6fb7f9cd6527<br>
Ancestors: Collections-dtl.731<br>
<br>
Modify HtmlReadWriter to enclose indented text within <pre></pre> to preserve formatting of, for example, code.<br>
<br>
=============== Diff against Collections-dtl.731 ===============<br>
<br>
Item was added:<br>
+ ----- Method: HtmlReadWriter>><wbr>linesWithAttributesIn:do: (in category 'writing') -----<br>
+ linesWithAttributesIn: aText do: aBlock<br>
+ "Evauate aBlock with a string and the emphasis for that string, guaranteeing<br>
+ that if the string contains a line break, it occurs at the end of the line."<br>
+ aText runs withStartStopAndValueDo:<br>
+ [:start :stop :attributes | | att idx startIdx |<br>
+ startIdx := start.<br>
+ [att := aText attributesAt: startIdx.<br>
+ idx := aText string indexOf: Character cr from: startIdx to: stop ifAbsent: stop.<br>
+ aBlock value: (aText string copyFrom: startIdx to: idx) value: att.<br>
+ idx < stop]<br>
+ whileTrue:<br>
+ [startIdx := idx + 1]]!<br>
<br>
Item was changed:<br>
----- Method: HtmlReadWriter>>nextPutText: (in category 'accessing') -----<br>
nextPutText: aText<br>
+ | atStartOfLine inIndent cr |<br>
+ atStartOfLine := true.<br>
+ inIndent := false.<br>
+ cr := Character cr.<br>
+ self linesWithAttributesIn: aText do:<br>
+ [:string :attributes | | indented |<br>
+ atStartOfLine ifTrue:<br>
+ [indented := string first == Character tab.<br>
+ indented ~~ inIndent ifTrue:<br>
+ [stream nextPutAll: (indented ifTrue: ['<pre>'] ifFalse: ['</pre>']).<br>
+ inIndent := indented]].<br>
+ attributes do: [:each | self writeStartTagFor: each].<br>
+ inIndent<br>
+ ifTrue: [self writePresentationContent: string]<br>
+ ifFalse: [self writeContent: string].<br>
+ attributes reverseDo: [:each | self writeEndTagFor: each].<br>
+ atStartOfLine := string last == cr].<br>
+ inIndent ifTrue:<br>
+ [stream nextPutAll: '</pre>']!<br>
-<br>
- aText runs<br>
- withStartStopAndValueDo: [:start :stop :attributes |<br>
- | att str |<br>
- att := aText attributesAt: start.<br>
- str := aText string copyFrom: start to: stop.<br>
-<br>
- att do: [:each | self writeStartTagFor: each].<br>
- self writeContent: str.<br>
- att reverse do: [:each | self writeEndTagFor: each]]!<br>
<br>
Item was added:<br>
+ ----- Method: HtmlReadWriter>><wbr>writePresentationContent: (in category 'writing') -----<br>
+ writePresentationContent: aString<br>
+<br>
+ aString do: [:char |<br>
+ char = Character tab<br>
+ ifTrue: [stream nextPutAll: ' ']<br>
+ ifFalse: [(String htmlEntities keyAtValue: char ifAbsent: [])<br>
+ ifNil: [stream nextPut: char]<br>
+ ifNotNil: [:escapeSequence |<br>
+ stream<br>
+ nextPut: $&;<br>
+ nextPutAll: escapeSequence;<br>
+ nextPut: $;]]]!<br>
<br>
Item was added:<br>
+ ----- Method: SequenceableCollection>><wbr>indexOf:from:to:ifAbsent: (in category 'accessing') -----<br>
+ indexOf: anElement from: start to: end ifAbsent: exceptionBlock<br>
+ "Answer the index of the first occurence of anElement from start to stop<br>
+ within the receiver. If the receiver does not contain anElement in the,<br>
+ range answer the result of evaluating the argument, exceptionBlock."<br>
+<br>
+ start to: end do:<br>
+ [:index |<br>
+ (self at: index) = anElement ifTrue: [^index]].<br>
+ ^exceptionBlock value!<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div>