nikita-volkov / neat-interpolation

A quasiquoter for neat and simple multiline text interpolation
http://hackage.haskell.org/package/neat-interpolation
MIT License
55 stars 16 forks source link

`text` eats all empty lines in the beginning and the end of the output #16

Closed vrom911 closed 4 years ago

vrom911 commented 7 years ago

If you have something like this:

myText = [text|

v I really need that lines  ^.

|]

you expect to have the output:

> myText

v I really need that lines  ^.

But instead it's just

> myText
v I really need that lines  ^.

My workaround was to have the endLine = "\n" and put it at first and last lines:

myText = [text|
$endline

v I really need that lines  ^.

$endline
|]

which is not very cool. It would be much nicer if this behavior can be configurable.

nikita-volkov commented 7 years ago

Yours is really a rare case, but anyways. Here's a new behaviour that I suggest:

myText1 =
  [text|
    abc
  |]

myText2 =
  [text|

    abc
  |]

myText3 =
  [text|

    abc

  |]

myText1 == "abc"
myText2 == "\nabc"
myText3 == "\nabc\n"
vrom911 commented 7 years ago

@nikita-volkov , thanks for your reply! I'm not sure that understood you correctly. What's the difference between what you suggest and my initial proposal? Sorry for my confusion.. :confused: The only thing I want is not to remove trailing and leading empty lines..

nikita-volkov commented 7 years ago

The difference from the current behaviour will be that instead of trimming all the blank lines, it will only drop 1 from each side (if they are at all present).

vrom911 commented 7 years ago

@nikita-volkov Okay, I see now. That'll do for me.

nikita-volkov commented 4 years ago

0.5 now provides trimming and untrimming variations of the quasiquoter. untrimming addresses the problem expressed in this thread.