"bearophile" <[email protected]> wrote in message news:[email protected]... > After a short discussion in D.learn I have created a tiny enhancement > request: > http://d.puremagic.com/issues/show_bug.cgi?id=6361 > > I show its text here too. It's not essential, it's a minor thing. >
Since this is re-posted here, I'll repost my response. Please note that this does properly handle bearophile's original problem, in addition to indenting. Also, individual parts of the functionality are available a la carte' as stripTop/Bottom/Right, and unindent: I created a (CTFEable) function normalize() (maybe could use a better name?): http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/util/text.d#L630 void foo() { if(blah) { // Works properly: writeln(" - First item: 150 - Second item: 200 -- Subitem 1 -- Subitem 2 - Third item: 105 ".normalize()); } } Another example: Do this: -------------------- void foo() { enum codeStr = q{ // Written in the D Programming Langauge // by John Doe int main() { return 0; } }.normalize(); } -------------------- Instead of this: -------------------- void foo() { enum codeStr = q{// Written in the D Programming Langauge // by John Doe int main() { return 0; }}; } -------------------- The resulting string is exactly the same. I'd be happy to work it into something appropriate for Phobos if people are intersted.
