sindresorhus / generate-github-markdown-css

Generate the CSS for github-markdown-css
MIT License
380 stars 77 forks source link

Fix extracting CSS variables with default value #18

Closed hyrious closed 1 year ago

hyrious commented 1 year ago

There are 2 issues in previous code:

  1. Applying CSS variables wrongly handled non-exist variables, resulting undefined at value. It should be left as is.

  2. GitHub added 2 new CSS variables with default fallback, previously the script does not handle this case well, it can correctly extract them now.

sindresorhus commented 1 year ago

When generating, I noticed that it now includes some things we don't want, like [data-dev-analytics-enabled]. Would you be able to remove that?

hyrious commented 1 year ago

I'd like to, looks like these unwanted styles are extracted from top level rules (since they may have chance to affect markdown body).

Previously we only have one forbidden rule [hidden][hidden], maybe it's time to disallow more selectors.

Let's print out these selectors to have a glance (omitting '.class', ':root', '::-webkit-whatever', 'p'..):

[data-color-mode=light][data-light-theme*=light]
[data-color-mode=dark][data-dark-theme*=light]
[data-color-mode=light][data-light-theme*=dark]
[data-color-mode=dark][data-dark-theme*=dark]
[data-color-mode]
[hidden]
[type=reset]
[type=submit]
[type=checkbox]
[type=radio]
[type=number]::-webkit-inner-spin-button
[type=number]::-webkit-outer-spin-button
[type=search]::-webkit-search-cancel-button
[type=search]::-webkit-search-decoration
[role=button]:focus
[role=button]:focus:not(:focus-visible)
[role=button]:focus-visible
[data-catalyst]
[data-catalyst-inline]
[data-a11y-animated-images=system] [data-animated-image]
[data-a11y-animated-images=disabled] [data-animated-image]
[data-color-mode=light][data-light-theme*=dark] ::selection
[data-color-mode=dark][data-dark-theme*=dark] ::selection
[data-dev-analytics-enabled] [data-feeds-analytics]
[data-dev-analytics-enabled] [data-feeds-analytics]::after
[data-dev-analytics-enabled] [data-feeds-analytics]:hover
[data-dev-analytics-enabled] [data-feeds-analytics]:hover::after
sindresorhus commented 1 year ago

maybe it's time to disallow more selectors.

👍