ruricolist/spinneret

Function call inserts a space into generated HTML

mfiano opened this issue · 5 comments

Hello, I just ran across this issue. Sometimes a function call will insert a space into the generated HTML. Best explained with an example (replace values with any function -- it does not matter which):

First without functions:

CL> (spinneret:with-html-string
      (:p "foo"
          "bar"
          "baz"))
"<p>foobarbaz"

and the inconsistent result when calling a function to produce the string, here with values:

CL> (spinneret:with-html-string
      (:p (values "foo")
          (values "bar")
          (values "baz")))
"<p>foo bar baz"

CL> (spinneret:with-html-string
      (:p (values "foo")
          "bar"
          (values "baz")))
"<p>foobar baz"

However it does not produce inconsistent results with:

CL> (spinneret:with-html-string
      (:p "foo"
          "bar"
          (values "baz")))
"<p>foobarbaz"

CL> (spinneret:with-html-string
      (:p (values "foo")
          "bar"
          "baz"))
"<p>foobarbaz"

I've pushed a potential fix for this to a new branch (literal-string-fix) using a different approach to pre-escaping literal strings. Would you mind trying it out?

Thanks for the quick response. I did test the new branch out, and while it does solve all the inconsistencies in the resulting string, it is still not usable for me with my currrent project. I need a means to not automatically insert spaces unless explicitly done so by user code. Does that make sense, and is it trivial to add such optional behavior with another special variable perhaps?

I added a flag to the same branch, *suppress-inserted-spaces*.

Great that solves my issues as far as spinneret can help anyway. There's still the annoyance that a when using *print-pretty* a string can start indented with the level of the tree and thus counts as a space to the renderer. I don't think spinneret can help much with this and I might as well disable the pretty printer. Thanks for the quick fix!

No problem. I'll merge it into master as soon as I have time to document the new flag.