typestyle / csx

Utility functions for TypeStyle
https://typestyle.github.io
MIT License
102 stars 14 forks source link

quote() doesn't escape ' or " #21

Closed notoriousb1t closed 7 years ago

notoriousb1t commented 7 years ago

Notes from @basarat in https://github.com/typestyle/csx/commit/cfd1fc39db457547e01282d21f1462e5c66b2481

notoriousb1t commented 7 years ago

I'm trying to figure out why we need to double escape the ' in the string.

basarat commented 7 years ago

There is no double escaping, only single escaping.

The JS strings are equivalent : "ta ' da" == 'ta \' da', i.e there is just a quote, no \' (slash + quote) in that string.

The string we want to output is 'ta \' da'. In js that can be written as "'ta \\' da'".

image

If someone gives us the string 'hello' e.g. "'hello'" in js

image

We want to write '\'hello\'' in CSS. Hence that transform. Hope that helps :rose:

notoriousb1t commented 7 years ago

The 'ta \' da' example helped me understand what you were talking about. You are talking about quotes inside the quoted string. 👍

notoriousb1t commented 7 years ago

Fixed in ef8b46d3220bd0d0d4794c22797ea93f5008b4c3