lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Sun, Apr 5, 2009 at 10:39 PM, Daniel Stephens <daniel@danielstephens.com> wrote:
The other option of course is to close the [[ ]] string, concatenate a "]]", then restart the [[ ]] string, though this has the disadvantage of not being a single string at compile time and requiring the concatenation to occur at runtime, it might be easier to implement for your case.

i.e. replace ]] in the input with ]].."]]"..[[

Daniel.


There's a subtle problem with that - if a long-string literal starts immediately with a new line, the new line gets removed. So any new-lines that immediately follow a ]] in the source string will get stripped. For this reason you should always prepend a new line to any long-string literals in generated source code, to remove the possibility of one being stripped out unexpectedly.

-Duncan