mikesol / purescript-deku

A PureScript web UI framework
https://deku-documentation.vercel.app/
Apache License 2.0
135 stars 12 forks source link

Pursx does not allow single-quotes for attribute definitions #96

Closed silky closed 3 months ago

silky commented 1 year ago

Thanks for this lovely library :) I'm having a great time.

Here's something I noticed; consider:

html = Proxy :: _
  """
  <div id="hello"></div>
  """

Completely fine; but this:

html = Proxy :: _
  """
  <div id='hello'></div>
  """

yields an error:

[1]   No type class instance was found for
[1]   
[1]     Deku.Pursx.PXTagPreAttrValue "~"
[1]                                  False
[1]                                  "div"
[1]                                  "\'"
[1]                                  "hello\'></div>\n  "
[1]                                  ()
[1]                                  ()
[1]                                  t5
[1]   
[1]   while solving type class constraint
[1]   
[1]     Deku.Pursx.PXTagAttrName "~"
[1]                              False
[1]                              "div"
[1]                              t3
[1]                              t4
[1]                              (() @Type)
[1]                              (() @Type)
[1]                              t5
[1]   
[1]   while applying a function makePursx
[1]     of type Reflectable @Symbol t0 String => PXStart "~" " " t0 t1 => RowToList @Type t1 t2 => PursxToElement t2 t1 => Proxy @Symbol t0 -> Record t1 -> Nut
[1]     to argument html
[1]   while inferring the type of makePursx html
[1]   in value declaration ...
[1]   
[1]   where t0 is an unknown type
[1]         t1 is an unknown type
[1]         t2 is an unknown type
[1]         t5 is an unknown type
[1]         t3 is an unknown type
[1]         t4 is an unknown type

For my text-editor's (vim) syntax highlighting, it'd be convenient to use single-quotes here so it doesn't get confused :)

image

mikesol commented 1 year ago

I didn't realize single quotes were allowed, but it looks like they are! https://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2. I'll make a PR modifying the parser, but in the meantime, I'd recommend using single quotes. Thanks!

mikesol commented 3 months ago

There's a PR now to fix this @ https://github.com/mikesol/purescript-deku/pull/123. Once it's merged, I'll let you know!

mikesol commented 3 months ago

Fixed with https://github.com/mikesol/purescript-deku/pull/125