View Single Post
Old 04-21-2021, 04:04 AM   #68
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
@chaley: is there a way to make the template output new lines. For example if I want to output all formats for a book separated by a new line? Or do I have to wrap the call to the formatter to maybe replace '\\n' with a new line (in Action Chains)?

Edit: Replacing '\\n' with newlines would be a really bad idea it can mess up file paths which can have the same character. I will think of a safer representation for a new line. Maybe a new_line() function that inserts a non-printable character.
The lexical analyser doesn't do any character escaping. The exception, which it gets wrong, is escaping quotes for example 'aa\'bb' that ends up as the string aa\'bb. Yes, the backslash is still there, which is wrong. I am looking for ways to fix this without breaking all strings containing backslashes.

If we use a "newline()" function, and presumably strcat(), then why not have it put a real newline in the string?

Note that by default leading and trailing whitespace is stripped (strip()). If you don't want that then call the formatter with strip_results=False.

EDIT: if strip_results is True then all white space, including newlines, is turned into a single space.

Last edited by chaley; 04-21-2021 at 05:01 AM.
chaley is offline   Reply With Quote