Quote:
Originally Posted by capink
Thanks. I am using it now and it seems to be working OK. But newline() is not highlighted and does not appear in the function reference, but it works as expected.
|
It is a function, not a keyword, so it isn't highlighted. I thought about making it a keyword but decided against it to avoid clashes with identifiers in existing templates.
You are right, I forgot to add the function to the function list. I will do that.
Question: for most formatter calls the newline() function won't do anything because the result has all contiguous white space converted to a single blank. It is then stripped. For example the template result "\nA \r\t\n B " becomes "A B". I am thinking of changing that behavior for GPM templates (but not SFM templates), removing the conversion-to-one-blank step. If I do then the above string would become "A \r\t\n B" (the leading and trailing whitespace is stripped but internal whitespace is not modified). I could also do strip(' '), removing leading & trailing blanks but leaving other whitespace intact. In this case the example result would be "\nA \r\t\n B" This change would make the newline() function generally usable and would permit formatting using tabs. (Of course that would require adding a tab() function.)
It is possible that someone has GPM templates that depend on the current callapse-white-space behavior, but I think the chances are very low, and in any event the template can be changed not to depend on collapsing spaces together.
I lean toward removing collapsing internal white space and stripping only blanks. What do you think?
BTW: the above change would mean you don't need to set strip_results because it would still do the strip() that you are doing.