<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 9, 2017 at 11:44 AM, Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span class="gmail-"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 9, 2017 at 8:16 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Tobias,<div><br></div><div>  ignore my email.  I'm reviewing your code.  But I will say that adding inst vars is making things more complicated too.  I added three methods to achieve what I wanted and you've added 8 and an inst var ;-)</div></div><div class="gmail_extra"><div><div class="gmail-m_-4581947028531159895h5"></div></div></div></blockquote></div><br></div></span><div class="gmail_extra">The problem with your indentation-based approach was that when just copying a whole method as HTML, it would insert a <pre> tag *after* the method pattern (because that was the first indented line).</div></div></blockquote><div><br></div><div>Thats not quite true.  My code adds the <pre> before indenting because of the variable initializations.  But it does indeed insert the closing </pre> after the last carriage return and that's a bug.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"> That's why Tobi added the TextDoit stuff, to specifically mark code ... It's still not ideal but we couldn't come up with a better way for unifying your blog-post-in-a-workspace with the regular just-copy-some-code. Ideas welcome :)</div></div></blockquote><div><br></div><div>When examining the end of line, the code could easily peek ahead and look at the next line.  This would allow it to add the </pre> before the last carriage return.  So to sketch the algorithm, the high-level iterator over texts breaks text into lines, arranging that line breaks occur only as the last character of the text, and the iterator provides the next character after the line break, or nil of none.  The code can then easily arrange to add the closing </pre> before the carriage return since it is informed of the character following the line break:</div><div><br></div><div><b style="color:rgb(0,0,0);font-family:-webkit-standard">linesWithAttributesIn:</b><font color="#000000" style="color:rgb(0,0,0);font-family:-webkit-standard"> </font><font color="#00007F" style="font-family:-webkit-standard">aText</font><font color="#000000" style="color:rgb(0,0,0);font-family:-webkit-standard"> </font><b style="color:rgb(0,0,0);font-family:-webkit-standard">do:</b><font color="#000000" style="color:rgb(0,0,0);font-family:-webkit-standard"> </font><font color="#00007F" style="font-family:-webkit-standard">aTrinaryBlock</font><font color="#000000" style="color:rgb(0,0,0);font-family:-webkit-standard"><br></font><pre style="color:rgb(0,0,0)"><font color="#000000">    </font><font color="#007F7F">"Evauate aTrinaryBlock with a string and the emphasis for that string, guaranteeing
</font><font color="#007F7F">     that if the string contains a line break, it occurs at the end of the line, and the
</font><font color="#007F7F">     chanarcter following the line break if it exists."</font><font color="#000000">
</font><font color="#000000">    </font><font color="#00007F">aText</font><font color="#000000"> </font><font color="#00007F">runs</font><font color="#000000"> </font><font color="#00007F">withStartStopAndValueDo:</font><font color="#000000">
</font><font color="#000000">        </font><font color="#000000">[</font><font color="#000000">:</font><font color="#00007F">start</font><font color="#000000"> </font><font color="#000000">:</font><font color="#00007F">stop</font><font color="#000000"> </font><font color="#000000">:</font><font color="#00007F">attributes</font><font color="#000000"> </font><font color="#7F7F7F">|</font><font color="#000000"> </font><font color="#7F7F7F">|</font><font color="#000000"> </font><font color="#7F7F7F">att</font><font color="#000000"> </font><font color="#7F7F7F">idx</font><font color="#000000"> </font><font color="#7F7F7F">startIdx</font><font color="#000000"> </font><font color="#7F7F7F">|</font><font color="#000000">
</font><font color="#000000">         </font><font color="#7F7F7F">startIdx</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#00007F">start</font><font color="#000000">.</font><font color="#000000">
</font><font color="#000000">         </font><font color="#007F00">[</font><font color="#7F7F7F">att</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#00007F">aText</font><font color="#000000"> </font><font color="#00007F">attributesAt:</font><font color="#000000"> </font><font color="#7F7F7F">startIdx</font><font color="#000000">.</font><font color="#000000">
</font><font color="#000000">          </font><font color="#7F7F7F">idx</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#00007F">aText</font><font color="#000000"> </font><font color="#00007F">string</font><font color="#000000"> </font><font color="#00007F">indexOf:</font><font color="#000000"> </font><font color="#000000">Character</font><font color="#000000"> </font><font color="#00007F">cr</font><font color="#000000"> </font><font color="#00007F">from:</font><font color="#000000"> </font><font color="#7F7F7F">startIdx</font><font color="#000000"> </font><font color="#00007F">to:</font><font color="#000000"> </font><font color="#00007F">stop</font><font color="#000000"> </font><font color="#00007F">ifAbsent:</font><font color="#000000"> </font><font color="#00007F">stop</font><font color="#000000">.</font><font color="#000000">
</font><font color="#000000">          </font><font color="#00007F">aTrinaryBlock</font><font color="#000000">
</font><font color="#000000">            </font><font color="#00007F">value:</font><font color="#000000"> </font><font color="#7F007F">(</font><font color="#00007F">aText</font><font color="#000000"> </font><font color="#00007F">string</font><font color="#000000"> </font><font color="#00007F">copyFrom:</font><font color="#000000"> </font><font color="#7F7F7F">startIdx</font><font color="#000000"> </font><font color="#00007F">to:</font><font color="#000000"> </font><font color="#7F7F7F">idx</font><font color="#7F007F">)</font><font color="#000000">
</font><font color="#000000">            </font><font color="#00007F">value:</font><font color="#000000"> </font><font color="#7F7F7F">att</font><font color="#000000">
</font><font color="#000000">            </font><font color="#00007F">value:</font><font color="#000000"> </font><font color="#7F007F">(</font><font color="#7F7F7F">idx</font><font color="#000000"> </font><font color="#00007F"><</font><font color="#000000"> </font><font color="#00007F">stop</font><font color="#000000"> </font><font color="#00007F">ifTrue:</font><font color="#000000"> </font><font color="#7F0000">[</font><font color="#00007F">aText</font><font color="#000000"> </font><font color="#00007F">string</font><font color="#000000"> </font><font color="#00007F">at:</font><font color="#000000"> </font><font color="#7F7F7F">idx</font><font color="#000000"> </font><font color="#00007F">+</font><font color="#000000"> </font><font color="#7F0000">1</font><font color="#7F0000">]</font><font color="#7F007F">)</font><font color="#000000">.</font><font color="#000000">
</font><font color="#000000">          </font><font color="#7F7F7F">idx</font><font color="#000000"> </font><font color="#00007F"><</font><font color="#000000"> </font><font color="#00007F">stop</font><font color="#007F00">]</font><font color="#000000">
</font><font color="#000000">            </font><font color="#00007F">whileTrue:</font><font color="#000000">
</font><font color="#000000">                </font><font color="#007F00">[</font><font color="#7F7F7F">startIdx</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#7F7F7F">idx</font><font color="#000000"> </font><font color="#00007F">+</font><font color="#000000"> </font><font color="#7F0000">1</font><font color="#007F00">]</font><font color="#000000">]</font></pre></div><div><br></div><div><br></div><div>BTW, it would be *really cool* if "copy html" also copied the generated text to the system (OS) paste buffer as formatted HTML so I wouldn't have to paste the generated HTML into a Workspace, say "export to file...", open the HTML file in a web browser, and copy that text :-(  (or am I missing a trick??)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span class="gmail-HOEnZb"><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">- Bert -</div></font></span></div>
<br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="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></div>