<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">I was thinking of keeping it really simple and having just a few main rules.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">1) using " means that the string contents are escaped</div><div class="gmail_default" style="font-family:verdana,sans-serif">2) using ' means that the string contents are unescaped/raw</div><div class="gmail_default" style="font-family:verdana,sans-serif">3) using """ or ''' means that it's a multi-line string and indentation erasure rules are in effect</div><div class="gmail_default" style="font-family:verdana,sans-serif">4) indentation erasure is from the least indented line (from start of line, not start of quote)</div><div class="gmail_default" style="font-family:verdana,sans-serif">5) the first line, if it contains only a newline, is removed entirely (this lets you just start your text on the next line)</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">I'm wibbly wobbly about the last line containing only a newline. I'm not sure whether to err on the side of caution and assume it's intentional, or remove it as well. At the moment I'm leaning toward assuming it's intentional.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">I'm also not entirely sure what to do in the case of mixed indentation. I could absolutely see the leading indentation being tabs (with the editor displaying them as equivalent to 4 spaces), but the slight indentation of one to three characters being spaces. </div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Here is the SQL example for reference to show what I mean:</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><pre style="white-space:pre-wrap;font-size:1em;font-family:Consolas,Inconsolata,Courier,monospace;line-height:1.2em;margin-top:1.2em;margin-bottom:1.2em"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em;color:rgb(51,51,51);display:block!important;background:rgb(248,248,248)"><span style="font-weight:bold">func</span> <span style="color:rgb(153,0,0);font-weight:bold">findMentions</span>(account: String) -> <span style="color:rgb(153,0,0);font-weight:bold">Array</span><String> {
<span style="font-weight:bold">let</span> db = databaseFactory().findDatabase()
<span style="font-weight:bold">let</span> q = '''<span style="color:rgb(68,85,136);font-weight:bold">SELECT</span> array_agg(<a href="http://mentioner.id/" target="_blank">mentioner.id</a>)
<span style="color:rgb(68,85,136);font-weight:bold">FROM</span> account
<span style="color:rgb(68,85,136);font-weight:bold">JOIN</span> mention <span style="color:rgb(68,85,136);font-weight:bold">ON</span> (<a href="http://account.id/" target="_blank">account.id</a> = mentioned)
<span style="color:rgb(68,85,136);font-weight:bold">JOIN</span> account <span style="color:rgb(68,85,136);font-weight:bold">AS</span> mentioner <span style="color:rgb(68,85,136);font-weight:bold">ON</span> (<a href="http://mentioner.id/" target="_blank">mentioner.id</a> = mentioner)
<span style="color:rgb(68,85,136);font-weight:bold">WHERE</span> account.handle = :<span style="color:rgb(0,128,128)">1</span>
<span style="color:rgb(68,85,136);font-weight:bold">ORDER</span> <span style="color:rgb(68,85,136);font-weight:bold">BY</span> timestamp <span style="color:rgb(68,85,136);font-weight:bold">DESC</span>
<span style="color:rgb(68,85,136);font-weight:bold">LIMIT</span> <span style="color:rgb(0,128,128)">1'''</span>
<span style="font-weight:bold">return</span> db.query(q).parameterize(account).run()
}
</code><div><br></div></pre></div><div class="gmail_extra"><div class="gmail_default" style="font-family:verdana,sans-serif">- Travis Tilley</div><br><div class="gmail_quote"><br></div>
</div></div>