mbylstra / html-to-elm

An online tool for converting HTML to elm-html. Go to
http://mbylstra.github.io/html-to-elm/
394 stars 23 forks source link

Double quotes not escaped for inline style #20

Open pietro909 opened 7 years ago

pietro909 commented 7 years ago

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\");" ]
  []
synalysis commented 6 years ago

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.