html-to-elm icon indicating copy to clipboard operation
html-to-elm copied to clipboard

Double quotes not escaped for inline style

Open pietro909 opened this issue 8 years ago • 1 comments

If you input:

<div style="background-image: url(&quot;avatar.jpg&quot;);"></div>

The result is:

div [ attribute "style" "background-image: url("avatar.jpg");" ]
  []

Which is not valid elm code. It should escape the double quotes:

div [ attribute "style" "background-image: url(\"avatar.jpg\");" ]
  []

pietro909 avatar Jan 31 '17 13:01 pietro909

A similar case is this multi-line attribute:

<div data-responsive="[{
  &quot;breakpoint&quot;: 1200,
  &quot;settings&quot;: {
  &quot;slidesToShow&quot;: 5
  }
  }]">
</div>

which is translated to this invalid Elm code:

div [ attribute "data-responsive" "[{
  "breakpoint": 1200,
  "settings": {
  "slidesToShow": 5
  }
  }]" ]
    []

Elm says:

Elm strings like "this" cannot contain newlines.

Hint: For strings that CAN contain newlines, say """this""" for Elm’s multi-line
string syntax. It allows unescaped newlines and double quotes.
Detected errors in 1 module.

synalysis avatar Oct 12 '18 14:10 synalysis