Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also escape octothorpe character in class name #76

Merged
merged 1 commit into from
Jan 22, 2022

Conversation

jamesnvc
Copy link
Contributor

Without this, using the "hash" syntax for colours generates invalid CSS (e.g. "bg-#000").

This could, I think, also be the following:

(defn dot [class]
  (str "." (string/replace class #"[^-a-zA-Z0-9]" "\\\\$0")))

Since, according to the CSS 2.1 spec only ASCII characters hyphens, a-z, A-Z, and 0-9 can appear unescaped.

Without this, using the "hash" syntax for colours generates invalid CSS (e.g. `"bg-#000"`).

This could, I think, also be the following:

```
(defn dot [class]
  (str "." (string/replace class #"[^-a-zA-Z0-9]" "\\$1")))
```

Since, according to [the CSS 2.1 spec](https://www.w3.org/TR/CSS21/syndata.html#characters) only ASCII characters hyphens, a-z, A-Z, and 0-9 can appear unescaped.
@green-coder
Copy link
Owner

Thank you for the fix and for the link to the spec.

@green-coder green-coder merged commit a81896e into green-coder:master Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants