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

Add css-(un)escape, allow using escaped selectors #19

Merged
merged 10 commits into from Jul 28, 2022

Conversation

aartaka
Copy link
Contributor

@aartaka aartaka commented Jul 27, 2022

This adds:

  • An ability to escape CSS strings (css-escape, API akin to CSS.escape()) and parse escaped ones back to literal values (css-unescape, a naïve reverse of css-escape).
  • Simplified identifier parsing, as per the CSS spec, instead of unrelated and more restrictive HTML spec.
  • The extension of the clss-name syntax rule to allow backslash-escaped characters (should it be #x1F to #xFF, actually? I've included all of ASCII just in case...)
  • The intuitive parsing of those in the matchers.

All in all, it fixes #13 (if you use css-escape on the class name) and allows for a safer and more reliable element selection.

@Shinmera, I've tried to optimize the hell out of css-escape and css-unescape, but I may have missed some important nit. For instance, how do you specify the element type of a string -- it should be character, right? SBCL complains about it being unspecified :/

parser.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
engine.lisp Outdated Show resolved Hide resolved
@aartaka
Copy link
Contributor Author

aartaka commented Jul 28, 2022

Should be all addressed now:

  • I've used do&cond in favor of loop.
  • css-unescape is now called when compiling selectors, not matching them.
  • escapable is a toplevel function now.

@aartaka
Copy link
Contributor Author

aartaka commented Jul 28, 2022

I've introduced some index-out-of-bounds mistakes while refactoring, they should be fixed now :P

parser.lisp Outdated Show resolved Hide resolved
parser.lisp Outdated Show resolved Hide resolved
@Shinmera
Copy link
Owner

Looks good (save for not upcasing t, but I'll let that slide for now.)

@Shinmera Shinmera merged commit f62b849 into Shinmera:master Jul 28, 2022
@aartaka
Copy link
Contributor Author

aartaka commented Jul 28, 2022

Ahhhh, right, I'm always forgetting about this stylistic convention of yours 😅

@aartaka aartaka deleted the css-escaping branch July 28, 2022 08:54
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.

Selecting CSS classes containing parentheses
2 participants