Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tailwindcss/typography

Package Overview
Dependencies
Maintainers
5
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tailwindcss/typography - npm Package Compare versions

Comparing version 0.0.0-insiders.79ce26f to 0.0.0-insiders.79f3f69

src/index.d.ts

52

CHANGELOG.md

@@ -10,4 +10,44 @@ # Changelog

- Nothing yet!
### Fixed
- Fix space between `<figcaption>` and `<pre>` ([#313](https://github.com/tailwindlabs/tailwindcss-typography/pull/313))
- Remove typography styles from `not-prose` elements in addition to their children ([#301](https://github.com/tailwindlabs/tailwindcss-typography/pull/301))
- Add `<picture>` styles ([#314](https://github.com/tailwindlabs/tailwindcss-typography/pull/314))
- Fix `prose-invert` when used with colors in light mode ([#315](https://github.com/tailwindlabs/tailwindcss-typography/pull/315))
- Add `<kbd>` styles ([#317](https://github.com/tailwindlabs/tailwindcss-typography/pull/317))
## [0.5.9] - 2023-01-10
### Fixed
- Ensure `p` styles are inserted before `.lead` styles ([#294](https://github.com/tailwindlabs/tailwindcss-typography/pull/294))
## [0.5.8] - 2022-11-07
### Fixed
- Fix selector when using a non-default class (e.g. `prose-sm`) ([#289](https://github.com/tailwindlabs/tailwindcss-typography/pull/289))
## [0.5.7] - 2022-09-02
### Fixed
- Update TypeScript types ([#284](https://github.com/tailwindlabs/tailwindcss-typography/pull/284))
## [0.5.6] - 2022-09-01
- Actually publish types ([a54c1a8](https://github.com/tailwindlabs/tailwindcss-typography/commit/a54c1a82a64efdf23aab57e62edaa369d1a857f1))
## [0.5.5] - 2022-09-01
### Added
- Add typescript types ([#283](https://github.com/tailwindlabs/tailwindcss-typography/pull/283))
## [0.5.4] - 2022-07-12
### Fixed
- Update `strong` and `code` color styles to inherit from parent ([#276](https://github.com/tailwindlabs/tailwindcss-typography/pull/276))
## [0.5.3] - 2022-07-07

@@ -20,3 +60,3 @@

## Fixed
### Fixed

@@ -135,3 +175,9 @@ - Fix prose elements `legacy` mode ([#259](https://github.com/tailwindlabs/tailwindcss-typography/pull/259))

[unreleased]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.3...HEAD
[unreleased]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.9...HEAD
[0.5.9]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.8...v0.5.9
[0.5.8]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.7...v0.5.8
[0.5.7]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.6...v0.5.7
[0.5.6]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.5...v0.5.6
[0.5.5]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.4...v0.5.5
[0.5.4]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.3...v0.5.4
[0.5.3]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.2...v0.5.3

@@ -138,0 +184,0 @@ [0.5.2]: https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.1...v0.5.2

9

package.json
{
"name": "@tailwindcss/typography",
"version": "0.0.0-insiders.79ce26f",
"version": "0.0.0-insiders.79f3f69",
"description": "A Tailwind CSS plugin for automatically styling plain HTML content with beautiful typographic defaults.",
"main": "src/index.js",
"types": "src/index.d.ts",
"files": [
"src/*.js",
"src/*.d.ts",
"dist/"

@@ -44,3 +46,3 @@ ],

"react-dom": "^17.0.2",
"tailwindcss": "^3.0.0-alpha.2"
"tailwindcss": "^3.2.2"
},

@@ -50,3 +52,4 @@ "dependencies": {

"lodash.isplainobject": "^4.0.6",
"lodash.merge": "^4.6.2"
"lodash.merge": "^4.6.2",
"postcss-selector-parser": "6.0.10"
},

@@ -53,0 +56,0 @@ "jest": {

<p>
<a href="https://tailwindcss.com/docs/typography-plugin#gh-light-mode-only" target="_blank">
<img src="./.github/logo-light.svg" alt="Tailwind CSS Typography" width="450" height="70">
<a href="https://tailwindcss.com/docs/typography-plugin" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-light.svg">
<img alt="Tailwind CSS Typography" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss-typography/HEAD/.github/logo-light.svg" width="450" height="70" style="max-width: 100%;">
</picture>
</a>
<a href="https://tailwindcss.com/docs/typography-plugin#gh-dark-mode-only" target="_blank">
<img src="./.github/logo-dark.svg" alt="Tailwind CSS Typography" width="450" height="70">
</a>
</p>

@@ -9,0 +10,0 @@

@@ -5,2 +5,3 @@ const plugin = require('tailwindcss/plugin')

const styles = require('./styles')
const { commonTrailingPseudos } = require('./utils')

@@ -12,28 +13,16 @@ const computed = {

function inWhere(selector, { className, prefix }) {
function inWhere(selector, { className, modifier, prefix }) {
let prefixedNot = prefix(`.not-${className}`).slice(1)
let selectorPrefix = selector.startsWith('>') ? `.${className} ` : ''
let selectorPrefix = selector.startsWith('>')
? `${modifier === 'DEFAULT' ? `.${className}` : `.${className}-${modifier}`} `
: ''
if (selector.endsWith('::before')) {
return `:where(${selectorPrefix}${selector.slice(
0,
-8
)}):not(:where([class~="${prefixedNot}"] *))::before`
}
// Parse the selector, if every component ends in the same pseudo element(s) then move it to the end
let [trailingPseudo, rebuiltSelector] = commonTrailingPseudos(selector)
if (selector.endsWith('::after')) {
return `:where(${selectorPrefix}${selector.slice(
0,
-7
)}):not(:where([class~="${prefixedNot}"] *))::after`
if (trailingPseudo) {
return `:where(${selectorPrefix}${rebuiltSelector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))${trailingPseudo}`
}
if (selector.endsWith('::marker')) {
return `:where(${selectorPrefix}${selector.slice(
0,
-8
)}):not(:where([class~="${prefixedNot}"] *))::marker`
}
return `:where(${selectorPrefix}${selector}):not(:where([class~="${prefixedNot}"] *))`
return `:where(${selectorPrefix}${selector}):not(:where([class~="${prefixedNot}"],[class~="${prefixedNot}"] *))`
}

@@ -45,3 +34,3 @@

function configToCss(config = {}, { target, className, prefix }) {
function configToCss(config = {}, { target, className, modifier, prefix }) {
function updateSelector(k, v) {

@@ -60,3 +49,3 @@ if (target === 'legacy') {

return [
inWhere(k, { className, prefix }),
inWhere(k, { className, modifier, prefix }),
v,

@@ -67,3 +56,3 @@ Object.fromEntries(Object.entries(v).map(([k, v]) => updateSelector(k, v))),

return [inWhere(k, { className, prefix }), v]
return [inWhere(k, { className, modifier, prefix }), v]
}

@@ -126,7 +115,9 @@

let selector = target === 'legacy'
? selectors.map(selector => `& ${selector}`)
: selectors.join(', ')
let selector =
target === 'legacy' ? selectors.map((selector) => `& ${selector}`) : selectors.join(', ')
addVariant(`${className}-${name}`, target === 'legacy' ? selector : `& :is(${inWhere(selector, options)})`)
addVariant(
`${className}-${name}`,
target === 'legacy' ? selector : `& :is(${inWhere(selector, options)})`
)
}

@@ -141,2 +132,3 @@

className,
modifier,
prefix,

@@ -143,0 +135,0 @@ }

@@ -9,2 +9,48 @@ const path = require('path')

let vars = `
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
`
let defaults = css`

@@ -14,45 +60,7 @@ *,

::after {
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
${vars}
}
::backdrop {
${vars}
}
`

@@ -137,36 +145,41 @@

}
.prose :where([class~='lead']):not(:where([class~='not-prose'] *)) {
.prose :where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-lead);
}
.prose :where(strong):not(:where([class~='not-prose'] *)) {
.prose :where(strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-bold);
font-weight: 600;
}
.prose :where(ol[type='A']):not(:where([class~='not-prose'] *)) {
.prose :where(ol[type='A']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
list-style-type: upper-alpha;
}
.prose :where(blockquote p:first-of-type):not(:where([class~='not-prose'] *))::before {
.prose
:where(blockquote p:first-of-type):not(:where([class~='not-prose'], [class~='not-prose']
*))::before {
content: open-quote;
}
.prose :where(blockquote p:last-of-type):not(:where([class~='not-prose'] *))::after {
.prose
:where(blockquote p:last-of-type):not(:where([class~='not-prose'], [class~='not-prose']
*))::after {
content: close-quote;
}
.prose :where(h4 strong):not(:where([class~='not-prose'] *)) {
.prose :where(h4 strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-weight: 700;
}
.prose :where(figure > *):not(:where([class~='not-prose'] *)) {
.prose :where(figure > *):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin: 0;
}
.prose :where(ol > li):not(:where([class~='not-prose'] *))::marker {
.prose :where(ol > li):not(:where([class~='not-prose'], [class~='not-prose'] *))::marker {
font-weight: 400;
color: var(--tw-prose-counters);
}
.prose :where(.prose > ul > li p):not(:where([class~='not-prose'] *)) {
.prose
:where(.prose > ul > li p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin-top: 16px;
margin-bottom: 16px;
}
.prose :where(code):not(:where([class~='not-prose'] *))::before {
.prose :where(code):not(:where([class~='not-prose'], [class~='not-prose'] *))::before {
content: '&#96;';
}
.prose :where(code):not(:where([class~='not-prose'] *))::after {
.prose :where(code):not(:where([class~='not-prose'], [class~='not-prose'] *))::after {
content: '&#96;';

@@ -179,2 +192,90 @@ }

test('variants', async () => {
let config = {
content: [{ raw: html`<div class="sm:prose hover:prose-lg lg:prose-lg"></div>` }],
theme: {
typography: {
DEFAULT: {
css: [
{
color: 'red',
p: {
color: 'lime',
},
'> ul > li': {
color: 'purple',
},
},
],
},
lg: {
css: {
color: 'green',
p: {
color: 'tomato',
},
'> ul > li': {
color: 'blue',
},
},
},
xl: {
css: {
color: 'yellow',
'> ul > li': {
color: 'hotpink',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toMatchFormattedCss(
css`
${defaults}
.hover\:prose-lg:hover {
color: green;
}
.hover\:prose-lg:hover :where(p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: tomato;
}
.hover\:prose-lg:hover
:where(.hover\:prose-lg:hover
> ul
> li):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: blue;
}
@media (min-width: 640px) {
.sm\:prose {
color: red;
}
.sm\:prose :where(p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: lime;
}
.sm\:prose
:where(.sm\:prose > ul > li):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: purple;
}
}
@media (min-width: 1024px) {
.lg\:prose-lg {
color: green;
}
.lg\:prose-lg :where(p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: tomato;
}
.lg\:prose-lg
:where(.lg\:prose-lg > ul > li):not(:where([class~='not-prose'], [class~='not-prose']
*)) {
color: blue;
}
}
`
)
})
})
test('modifiers', async () => {

@@ -241,2 +342,5 @@ let config = {

},
'> ul > li': {
paddingLeft: '12px',
},
h1: {

@@ -273,32 +377,36 @@ fontSize: '48px',

}
.prose :where([class~='lead']):not(:where([class~='not-prose'] *)) {
.prose :where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-lead);
}
.prose :where(strong):not(:where([class~='not-prose'] *)) {
.prose :where(strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-bold);
font-weight: 600;
}
.prose :where(ol[type='A']):not(:where([class~='not-prose'] *)) {
.prose :where(ol[type='A']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
list-style-type: upper-alpha;
}
.prose :where(blockquote p:first-of-type):not(:where([class~='not-prose'] *))::before {
.prose
:where(blockquote p:first-of-type):not(:where([class~='not-prose'], [class~='not-prose']
*))::before {
content: open-quote;
}
.prose :where(blockquote p:last-of-type):not(:where([class~='not-prose'] *))::after {
.prose
:where(blockquote p:last-of-type):not(:where([class~='not-prose'], [class~='not-prose']
*))::after {
content: close-quote;
}
.prose :where(h4 strong):not(:where([class~='not-prose'] *)) {
.prose :where(h4 strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-weight: 700;
}
.prose :where(figure > *):not(:where([class~='not-prose'] *)) {
.prose :where(figure > *):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin: 0;
}
.prose :where(ol > li):not(:where([class~='not-prose'] *))::marker {
.prose :where(ol > li):not(:where([class~='not-prose'], [class~='not-prose'] *))::marker {
font-weight: 400;
color: var(--tw-prose-counters);
}
.prose :where(code):not(:where([class~='not-prose'] *))::before {
.prose :where(code):not(:where([class~='not-prose'], [class~='not-prose'] *))::before {
content: '&#96;';
}
.prose :where(code):not(:where([class~='not-prose'] *))::after {
.prose :where(code):not(:where([class~='not-prose'], [class~='not-prose'] *))::after {
content: '&#96;';

@@ -310,14 +418,19 @@ }

}
.prose-lg :where(p):not(:where([class~='not-prose'] *)) {
.prose-lg :where(p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin-top: 24px;
margin-bottom: 24px;
}
.prose-lg :where([class~='lead']):not(:where([class~='not-prose'] *)) {
.prose-lg
:where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-size: 22px;
}
.prose-lg :where(blockquote):not(:where([class~='not-prose'] *)) {
.prose-lg :where(blockquote):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin-top: 40px;
margin-bottom: 40px;
}
.prose-lg :where(h1):not(:where([class~='not-prose'] *)) {
.prose-lg
:where(.prose-lg > ul > li):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
padding-left: 12px;
}
.prose-lg :where(h1):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-size: 48px;

@@ -327,3 +440,3 @@ margin-top: 0;

}
.prose-lg :where(h2):not(:where([class~='not-prose'] *)) {
.prose-lg :where(h2):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-size: 30px;

@@ -333,3 +446,3 @@ margin-top: 56px;

}
.prose-lg :where(h3):not(:where([class~='not-prose'] *)) {
.prose-lg :where(h3):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-size: 24px;

@@ -347,3 +460,5 @@ margin-top: 40px;

plugins: [typographyPlugin({ target: 'legacy' })],
content: [{ raw: html`<div class="prose prose-h1:text-center prose-headings:text-ellipsis"></div>` }],
content: [
{ raw: html`<div class="prose prose-h1:text-center prose-headings:text-ellipsis"></div>` },
],
theme: {

@@ -524,33 +639,44 @@ typography: {

}
.markdown :where([class~='lead']):not(:where([class~='not-markdown'] *)) {
.markdown
:where([class~='lead']):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
color: var(--tw-prose-lead);
}
.markdown :where(strong):not(:where([class~='not-markdown'] *)) {
.markdown :where(strong):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
color: var(--tw-prose-bold);
font-weight: 600;
}
.markdown :where(ol[type='A']):not(:where([class~='not-markdown'] *)) {
.markdown
:where(ol[type='A']):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
list-style-type: upper-alpha;
}
.markdown
:where(blockquote p:first-of-type):not(:where([class~='not-markdown'] *))::before {
:where(blockquote
p:first-of-type):not(:where([class~='not-markdown'], [class~='not-markdown']
*))::before {
content: open-quote;
}
.markdown :where(blockquote p:last-of-type):not(:where([class~='not-markdown'] *))::after {
.markdown
:where(blockquote
p:last-of-type):not(:where([class~='not-markdown'], [class~='not-markdown'] *))::after {
content: close-quote;
}
.markdown :where(h4 strong):not(:where([class~='not-markdown'] *)) {
.markdown
:where(h4 strong):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
font-weight: 700;
}
.markdown :where(figure > *):not(:where([class~='not-markdown'] *)) {
.markdown
:where(figure > *):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
margin: 0;
}
.markdown :where(ol > li):not(:where([class~='not-markdown'] *))::marker {
.markdown
:where(ol > li):not(:where([class~='not-markdown'], [class~='not-markdown'] *))::marker {
font-weight: 400;
color: var(--tw-prose-counters);
}
.markdown :where(code):not(:where([class~='not-markdown'] *))::before {
.markdown
:where(code):not(:where([class~='not-markdown'], [class~='not-markdown'] *))::before {
content: '&#96;';
}
.markdown :where(code):not(:where([class~='not-markdown'] *))::after {
.markdown
:where(code):not(:where([class~='not-markdown'], [class~='not-markdown'] *))::after {
content: '&#96;';

@@ -630,99 +756,121 @@ }

}
.prose :where([class~='lead']):not(:where([class~='not-prose'] *)) {
.prose :where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-lead);
}
.prose :where(strong):not(:where([class~='not-prose'] *)) {
.prose :where(strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-bold);
font-weight: 600;
}
.prose :where(h4 strong):not(:where([class~='not-prose'] *)) {
.prose :where(h4 strong):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
font-weight: 700;
}
.prose-headings\:underline
:is(:where(h1, h2, h3, h4, h5, h6, th):not(:where([class~='not-prose'] *))) {
:is(:where(h1, h2, h3, h4, h5, h6, th):not(:where([class~='not-prose'], [class~='not-prose']
*))) {
text-decoration-line: underline;
}
.prose-h1\:text-3xl :is(:where(h1):not(:where([class~='not-prose'] *))) {
.prose-h1\:text-3xl
:is(:where(h1):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 1.875rem;
line-height: 2.25rem;
}
.prose-h2\:text-2xl :is(:where(h2):not(:where([class~='not-prose'] *))) {
.prose-h2\:text-2xl
:is(:where(h2):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 1.5rem;
line-height: 2rem;
}
.prose-h3\:text-xl :is(:where(h3):not(:where([class~='not-prose'] *))) {
.prose-h3\:text-xl
:is(:where(h3):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 1.25rem;
line-height: 1.75rem;
}
.prose-h4\:text-lg :is(:where(h4):not(:where([class~='not-prose'] *))) {
.prose-h4\:text-lg
:is(:where(h4):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 1.125rem;
line-height: 1.75rem;
}
.prose-p\:text-gray-700 :is(:where(p):not(:where([class~='not-prose'] *))) {
.prose-p\:text-gray-700
:is(:where(p):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
}
.prose-a\:font-bold :is(:where(a):not(:where([class~='not-prose'] *))) {
.prose-a\:font-bold
:is(:where(a):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-weight: 700;
}
.prose-blockquote\:italic :is(:where(blockquote):not(:where([class~='not-prose'] *))) {
.prose-blockquote\:italic
:is(:where(blockquote):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-style: italic;
}
.prose-figure\:mx-auto :is(:where(figure):not(:where([class~='not-prose'] *))) {
.prose-figure\:mx-auto
:is(:where(figure):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
margin-left: auto;
margin-right: auto;
}
.prose-figcaption\:opacity-75 :is(:where(figcaption):not(:where([class~='not-prose'] *))) {
.prose-figcaption\:opacity-75
:is(:where(figcaption):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
opacity: 0.75;
}
.prose-strong\:font-medium :is(:where(strong):not(:where([class~='not-prose'] *))) {
.prose-strong\:font-medium
:is(:where(strong):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-weight: 500;
}
.prose-em\:italic :is(:where(em):not(:where([class~='not-prose'] *))) {
.prose-em\:italic
:is(:where(em):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-style: italic;
}
.prose-code\:font-mono :is(:where(code):not(:where([class~='not-prose'] *))) {
.prose-code\:font-mono
:is(:where(code):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
}
.prose-pre\:font-mono :is(:where(pre):not(:where([class~='not-prose'] *))) {
.prose-pre\:font-mono
:is(:where(pre):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
}
.prose-ol\:pl-6 :is(:where(ol):not(:where([class~='not-prose'] *))) {
.prose-ol\:pl-6 :is(:where(ol):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
padding-left: 1.5rem;
}
.prose-ul\:pl-8 :is(:where(ul):not(:where([class~='not-prose'] *))) {
.prose-ul\:pl-8 :is(:where(ul):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
padding-left: 2rem;
}
.prose-li\:my-4 :is(:where(li):not(:where([class~='not-prose'] *))) {
.prose-li\:my-4 :is(:where(li):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
margin-top: 1rem;
margin-bottom: 1rem;
}
.prose-table\:my-8 :is(:where(table):not(:where([class~='not-prose'] *))) {
.prose-table\:my-8
:is(:where(table):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
margin-top: 2rem;
margin-bottom: 2rem;
}
.prose-thead\:border-red-300 :is(:where(thead):not(:where([class~='not-prose'] *))) {
.prose-thead\:border-red-300
:is(:where(thead):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
--tw-border-opacity: 1;
border-color: rgb(252 165 165 / var(--tw-border-opacity));
}
.prose-tr\:border-red-200 :is(:where(tr):not(:where([class~='not-prose'] *))) {
.prose-tr\:border-red-200
:is(:where(tr):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
--tw-border-opacity: 1;
border-color: rgb(254 202 202 / var(--tw-border-opacity));
}
.prose-th\:text-left :is(:where(th):not(:where([class~='not-prose'] *))) {
.prose-th\:text-left
:is(:where(th):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
text-align: left;
}
.prose-img\:rounded-lg :is(:where(img):not(:where([class~='not-prose'] *))) {
.prose-img\:rounded-lg
:is(:where(img):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
border-radius: 0.5rem;
}
.prose-video\:my-12 :is(:where(video):not(:where([class~='not-prose'] *))) {
.prose-video\:my-12
:is(:where(video):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
margin-top: 3rem;
margin-bottom: 3rem;
}
.prose-hr\:border-t-2 :is(:where(hr):not(:where([class~='not-prose'] *))) {
.prose-hr\:border-t-2
:is(:where(hr):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
border-top-width: 2px;
}
.prose-lead\:italic :is(:where([class~="lead"]):not(:where([class~="not-prose"] *))) {
.prose-lead\:italic
:is(:where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-style: italic;

@@ -803,44 +951,54 @@ }

}
.markdown :where([class~='lead']):not(:where([class~='not-markdown'] *)) {
.markdown
:where([class~='lead']):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
color: var(--tw-prose-lead);
}
.markdown :where(strong):not(:where([class~='not-markdown'] *)) {
.markdown :where(strong):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
color: var(--tw-prose-bold);
font-weight: 600;
}
.markdown :where(h4 strong):not(:where([class~='not-markdown'] *)) {
.markdown
:where(h4 strong):not(:where([class~='not-markdown'], [class~='not-markdown'] *)) {
font-weight: 700;
}
.markdown-headings\:underline
:is(:where(h1, h2, h3, h4, h5, h6, th):not(:where([class~='not-markdown'] *))) {
:is(:where(h1, h2, h3, h4, h5, h6, th):not(:where([class~='not-markdown'], [class~='not-markdown']
*))) {
text-decoration-line: underline;
}
.markdown-h1\:text-3xl :is(:where(h1):not(:where([class~='not-markdown'] *))) {
.markdown-h1\:text-3xl
:is(:where(h1):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-size: 1.875rem;
line-height: 2.25rem;
}
.markdown-h2\:text-2xl :is(:where(h2):not(:where([class~='not-markdown'] *))) {
.markdown-h2\:text-2xl
:is(:where(h2):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-size: 1.5rem;
line-height: 2rem;
}
.markdown-h3\:text-xl :is(:where(h3):not(:where([class~='not-markdown'] *))) {
.markdown-h3\:text-xl
:is(:where(h3):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-size: 1.25rem;
line-height: 1.75rem;
}
.markdown-h4\:text-lg :is(:where(h4):not(:where([class~='not-markdown'] *))) {
.markdown-h4\:text-lg
:is(:where(h4):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-size: 1.125rem;
line-height: 1.75rem;
}
.markdown-p\:text-gray-700 :is(:where(p):not(:where([class~='not-markdown'] *))) {
.markdown-p\:text-gray-700
:is(:where(p):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
}
.markdown-a\:font-bold :is(:where(a):not(:where([class~='not-markdown'] *))) {
.markdown-a\:font-bold
:is(:where(a):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-weight: 700;
}
.markdown-blockquote\:italic
:is(:where(blockquote):not(:where([class~='not-markdown'] *))) {
:is(:where(blockquote):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-style: italic;
}
.markdown-figure\:mx-auto :is(:where(figure):not(:where([class~='not-markdown'] *))) {
.markdown-figure\:mx-auto
:is(:where(figure):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
margin-left: auto;

@@ -850,55 +1008,71 @@ margin-right: auto;

.markdown-figcaption\:opacity-75
:is(:where(figcaption):not(:where([class~='not-markdown'] *))) {
:is(:where(figcaption):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
opacity: 0.75;
}
.markdown-strong\:font-medium :is(:where(strong):not(:where([class~='not-markdown'] *))) {
.markdown-strong\:font-medium
:is(:where(strong):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-weight: 500;
}
.markdown-em\:italic :is(:where(em):not(:where([class~='not-markdown'] *))) {
.markdown-em\:italic
:is(:where(em):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-style: italic;
}
.markdown-code\:font-mono :is(:where(code):not(:where([class~='not-markdown'] *))) {
.markdown-code\:font-mono
:is(:where(code):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
}
.markdown-pre\:font-mono :is(:where(pre):not(:where([class~='not-markdown'] *))) {
.markdown-pre\:font-mono
:is(:where(pre):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
}
.markdown-ol\:pl-6 :is(:where(ol):not(:where([class~='not-markdown'] *))) {
.markdown-ol\:pl-6
:is(:where(ol):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
padding-left: 1.5rem;
}
.markdown-ul\:pl-8 :is(:where(ul):not(:where([class~='not-markdown'] *))) {
.markdown-ul\:pl-8
:is(:where(ul):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
padding-left: 2rem;
}
.markdown-li\:my-4 :is(:where(li):not(:where([class~='not-markdown'] *))) {
.markdown-li\:my-4
:is(:where(li):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
margin-top: 1rem;
margin-bottom: 1rem;
}
.markdown-table\:my-8 :is(:where(table):not(:where([class~='not-markdown'] *))) {
.markdown-table\:my-8
:is(:where(table):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
margin-top: 2rem;
margin-bottom: 2rem;
}
.markdown-thead\:border-red-300 :is(:where(thead):not(:where([class~='not-markdown'] *))) {
.markdown-thead\:border-red-300
:is(:where(thead):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
--tw-border-opacity: 1;
border-color: rgb(252 165 165 / var(--tw-border-opacity));
}
.markdown-tr\:border-red-200 :is(:where(tr):not(:where([class~='not-markdown'] *))) {
.markdown-tr\:border-red-200
:is(:where(tr):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
--tw-border-opacity: 1;
border-color: rgb(254 202 202 / var(--tw-border-opacity));
}
.markdown-th\:text-left :is(:where(th):not(:where([class~='not-markdown'] *))) {
.markdown-th\:text-left
:is(:where(th):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
text-align: left;
}
.markdown-img\:rounded-lg :is(:where(img):not(:where([class~='not-markdown'] *))) {
.markdown-img\:rounded-lg
:is(:where(img):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
border-radius: 0.5rem;
}
.markdown-video\:my-12 :is(:where(video):not(:where([class~='not-markdown'] *))) {
.markdown-video\:my-12
:is(:where(video):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
margin-top: 3rem;
margin-bottom: 3rem;
}
.markdown-hr\:border-t-2 :is(:where(hr):not(:where([class~='not-markdown'] *))) {
.markdown-hr\:border-t-2
:is(:where(hr):not(:where([class~='not-markdown'], [class~='not-markdown'] *))) {
border-top-width: 2px;
}
.markdown-lead\:italic :is(:where([class~="lead"]):not(:where([class~="not-markdown"] *))) {
.markdown-lead\:italic
:is(:where([class~='lead']):not(:where([class~='not-markdown'], [class~='not-markdown']
*))) {
font-style: italic;

@@ -979,3 +1153,3 @@ }

expect(result.css).toIncludeCss(css`
.prose :where(a):not(:where([class~='not-prose'] *)) {
.prose :where(a):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: #888;

@@ -988,3 +1162,3 @@ text-decoration: underline;

expect(result.css).toIncludeCss(css`
.prose :where(a):not(:where([class~='not-prose'] *)):hover {
.prose :where(a):not(:where([class~='not-prose'], [class~='not-prose'] *)):hover {
color: #ff0000;

@@ -1008,7 +1182,7 @@ }

expect(result.css).toIncludeCss(css`
.prose-h5\:text-sm :is(:where(h5):not(:where([class~='not-prose'] *))) {
.prose-h5\:text-sm :is(:where(h5):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 0.875rem;
line-height: 1.25rem;
}
.prose-h6\:text-xl :is(:where(h6):not(:where([class~='not-prose'] *))) {
.prose-h6\:text-xl :is(:where(h6):not(:where([class~='not-prose'], [class~='not-prose'] *))) {
font-size: 1.25rem;

@@ -1020,1 +1194,238 @@ line-height: 1.75rem;

})
it('should not break with multiple selectors with pseudo elements using variants', () => {
let config = {
darkMode: 'class',
plugins: [typographyPlugin()],
content: [
{
raw: html`<div class="dark:prose"></div>`,
},
],
theme: {
typography: {
DEFAULT: {
css: {
'ol li::before, ul li::before': {
color: 'red',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(css`
.dark
.dark\:prose
:where(ol li, ul li):not(:where([class~='not-prose'], [class~='not-prose'] *))::before {
color: red;
}
`)
})
})
it('lifts all common, trailing pseudo elements when the same across all selectors', () => {
let config = {
darkMode: 'class',
plugins: [typographyPlugin()],
content: [
{
raw: html`<div class="prose dark:prose"></div>`,
},
],
theme: {
typography: {
DEFAULT: {
css: {
'ol li::marker::before, ul li::marker::before': {
color: 'red',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(css`
.prose
:where(ol li, ul li):not(:where([class~='not-prose'], [class~='not-prose']
*))::marker::before {
color: red;
}
`)
// TODO: The output here is a bug in tailwindcss variant selector rewriting
// IT should be ::marker::before
expect(result.css).toIncludeCss(css`
.dark
.dark\:prose
:where(ol li, ul li):not(:where([class~='not-prose'], [class~='not-prose']
*))::before::marker {
color: red;
}
`)
})
})
it('does not modify selectors with differing pseudo elements', () => {
let config = {
darkMode: 'class',
plugins: [typographyPlugin()],
content: [
{
raw: html`<div class="prose dark:prose"></div>`,
},
],
theme: {
typography: {
DEFAULT: {
css: {
'ol li::before, ul li::after': {
color: 'red',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(css`
.prose
:where(ol li::before, ul li::after):not(:where([class~='not-prose'], [class~='not-prose']
*)) {
color: red;
}
`)
// TODO: The output here is a bug in tailwindcss variant selector rewriting
expect(result.css).toIncludeCss(css`
.dark
.dark\:prose
:where(ol li, ul li):not(:where([class~='not-prose'], [class~='not-prose'] *))::before,
::after {
color: red;
}
`)
})
})
it('lifts only the common, trailing pseudo elements from selectors', () => {
let config = {
darkMode: 'class',
plugins: [typographyPlugin()],
content: [
{
raw: html`<div class="prose dark:prose"></div>`,
},
],
theme: {
typography: {
DEFAULT: {
css: {
'ol li::scroll-thumb::before, ul li::scroll-track::before': {
color: 'red',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(css`
.prose
:where(ol li::scroll-thumb, ul
li::scroll-track):not(:where([class~='not-prose'], [class~='not-prose'] *))::before {
color: red;
}
`)
// TODO: The output here is a bug in tailwindcss variant selector rewriting
expect(result.css).toIncludeCss(css`
.dark
.dark\:prose
:where(ol li, ul li):not(:where([class~='not-prose'], [class~='not-prose']
*))::scroll-thumb,
::scroll-track,
::before {
color: red;
}
`)
})
})
it('ignores common non-trailing pseudo-elements in selectors', () => {
let config = {
darkMode: 'class',
plugins: [typographyPlugin()],
content: [
{
raw: html`<div class="prose dark:prose"></div>`,
},
],
theme: {
typography: {
DEFAULT: {
css: {
'ol li::before::scroll-thumb, ul li::before::scroll-track': {
color: 'red',
},
},
},
},
},
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(css`
.prose
:where(ol li::before::scroll-thumb, ul
li::before::scroll-track):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: red;
}
`)
// TODO: The output here is a bug in tailwindcss variant selector rewriting
expect(result.css).toIncludeCss(css`
.dark
.dark\:prose
:where(ol li::scroll-thumb, ul
li::scroll-track):not(:where([class~='not-prose'], [class~='not-prose'] *))::before,
::before {
color: red;
}
`)
})
})
test('lead styles are inserted after paragraph styles', async () => {
let config = {
content: [{ raw: html`<div class="prose"></div>` }],
}
return run(config).then((result) => {
expect(result.css).toIncludeCss(
css`
.prose {
color: var(--tw-prose-body);
max-width: 65ch;
}
.prose :where(p):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
margin-top: 1.25em;
margin-bottom: 1.25em;
}
.prose :where([class~='lead']):not(:where([class~='not-prose'], [class~='not-prose'] *)) {
color: var(--tw-prose-lead);
font-size: 1.25em;
line-height: 1.6;
margin-top: 1.2em;
margin-bottom: 1.2em;
}
`
)
})
})

@@ -10,2 +10,10 @@ const colors = require('tailwindcss/colors')

const em = (px, base) => `${round(px / base)}em`
const hexToRgb = (hex) => {
hex = hex.replace('#', '')
hex = hex.length === 3 ? hex.replace(/./g, '$&$&') : hex
const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)
return `${r} ${g} ${b}`
}

@@ -60,18 +68,21 @@ let defaultModifiers = {

},
video: {
picture: {
marginTop: em(24, 14),
marginBottom: em(24, 14),
},
figure: {
'picture > img': {
marginTop: '0',
marginBottom: '0',
},
video: {
marginTop: em(24, 14),
marginBottom: em(24, 14),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
kbd: {
fontSize: em(12, 14),
lineHeight: round(16 / 12),
marginTop: em(8, 12),
borderRadius: rem(5),
paddingTop: em(2, 14),
paddingRight: em(5, 14),
paddingBottom: em(2, 14),
paddingLeft: em(5, 14),
},

@@ -181,2 +192,15 @@ code: {

},
figure: {
marginTop: em(24, 14),
marginBottom: em(24, 14),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
fontSize: em(12, 14),
lineHeight: round(16 / 12),
marginTop: em(8, 12),
},
},

@@ -240,18 +264,21 @@ {

},
video: {
picture: {
marginTop: em(32, 16),
marginBottom: em(32, 16),
},
figure: {
'picture > img': {
marginTop: '0',
marginBottom: '0',
},
video: {
marginTop: em(32, 16),
marginBottom: em(32, 16),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
kbd: {
fontSize: em(14, 16),
lineHeight: round(20 / 14),
marginTop: em(12, 14),
borderRadius: rem(5),
paddingTop: em(3, 16),
paddingRight: em(6, 16),
paddingBottom: em(3, 16),
paddingLeft: em(6, 16),
},

@@ -361,2 +388,15 @@ code: {

},
figure: {
marginTop: em(32, 16),
marginBottom: em(32, 16),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
fontSize: em(14, 16),
lineHeight: round(20 / 14),
marginTop: em(12, 14),
},
},

@@ -420,18 +460,21 @@ {

},
video: {
picture: {
marginTop: em(32, 18),
marginBottom: em(32, 18),
},
figure: {
'picture > img': {
marginTop: '0',
marginBottom: '0',
},
video: {
marginTop: em(32, 18),
marginBottom: em(32, 18),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
kbd: {
fontSize: em(16, 18),
lineHeight: round(24 / 16),
marginTop: em(16, 16),
borderRadius: rem(5),
paddingTop: em(4, 18),
paddingRight: em(8, 18),
paddingBottom: em(4, 18),
paddingLeft: em(8, 18),
},

@@ -541,2 +584,15 @@ code: {

},
figure: {
marginTop: em(32, 18),
marginBottom: em(32, 18),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
fontSize: em(16, 18),
lineHeight: round(24 / 16),
marginTop: em(16, 16),
},
},

@@ -600,18 +656,21 @@ {

},
video: {
picture: {
marginTop: em(40, 20),
marginBottom: em(40, 20),
},
figure: {
'picture > img': {
marginTop: '0',
marginBottom: '0',
},
video: {
marginTop: em(40, 20),
marginBottom: em(40, 20),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
kbd: {
fontSize: em(18, 20),
lineHeight: round(28 / 18),
marginTop: em(18, 18),
borderRadius: rem(5),
paddingTop: em(5, 20),
paddingRight: em(8, 20),
paddingBottom: em(5, 20),
paddingLeft: em(8, 20),
},

@@ -721,2 +780,15 @@ code: {

},
figure: {
marginTop: em(40, 20),
marginBottom: em(40, 20),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
fontSize: em(18, 20),
lineHeight: round(28 / 18),
marginTop: em(18, 18),
},
},

@@ -780,18 +852,21 @@ {

},
video: {
picture: {
marginTop: em(48, 24),
marginBottom: em(48, 24),
},
figure: {
'picture > img': {
marginTop: '0',
marginBottom: '0',
},
video: {
marginTop: em(48, 24),
marginBottom: em(48, 24),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
kbd: {
fontSize: em(20, 24),
lineHeight: round(32 / 20),
marginTop: em(20, 20),
borderRadius: rem(6),
paddingTop: em(6, 24),
paddingRight: em(8, 24),
paddingBottom: em(6, 24),
paddingLeft: em(8, 24),
},

@@ -901,2 +976,15 @@ code: {

},
figure: {
marginTop: em(48, 24),
marginBottom: em(48, 24),
},
'figure > *': {
marginTop: '0',
marginBottom: '0',
},
figcaption: {
fontSize: em(20, 24),
lineHeight: round(32 / 20),
marginTop: em(20, 20),
},
},

@@ -914,24 +1002,2 @@ {

// Invert (for dark mode)
invert: {
css: {
'--tw-prose-body': 'var(--tw-prose-invert-body)',
'--tw-prose-headings': 'var(--tw-prose-invert-headings)',
'--tw-prose-lead': 'var(--tw-prose-invert-lead)',
'--tw-prose-links': 'var(--tw-prose-invert-links)',
'--tw-prose-bold': 'var(--tw-prose-invert-bold)',
'--tw-prose-counters': 'var(--tw-prose-invert-counters)',
'--tw-prose-bullets': 'var(--tw-prose-invert-bullets)',
'--tw-prose-hr': 'var(--tw-prose-invert-hr)',
'--tw-prose-quotes': 'var(--tw-prose-invert-quotes)',
'--tw-prose-quote-borders': 'var(--tw-prose-invert-quote-borders)',
'--tw-prose-captions': 'var(--tw-prose-invert-captions)',
'--tw-prose-code': 'var(--tw-prose-invert-code)',
'--tw-prose-pre-code': 'var(--tw-prose-invert-pre-code)',
'--tw-prose-pre-bg': 'var(--tw-prose-invert-pre-bg)',
'--tw-prose-th-borders': 'var(--tw-prose-invert-th-borders)',
'--tw-prose-td-borders': 'var(--tw-prose-invert-td-borders)',
},
},
// Gray color themes

@@ -952,2 +1018,4 @@

'--tw-prose-captions': colors.slate[500],
'--tw-prose-kbd': colors.slate[900],
'--tw-prose-kbd-shadows': hexToRgb(colors.slate[900]),
'--tw-prose-code': colors.slate[900],

@@ -969,2 +1037,4 @@ '--tw-prose-pre-code': colors.slate[200],

'--tw-prose-invert-captions': colors.slate[400],
'--tw-prose-invert-kbd': colors.white,
'--tw-prose-invert-kbd-shadows': hexToRgb(colors.white),
'--tw-prose-invert-code': colors.white,

@@ -991,2 +1061,4 @@ '--tw-prose-invert-pre-code': colors.slate[300],

'--tw-prose-captions': colors.gray[500],
'--tw-prose-kbd': colors.gray[900],
'--tw-prose-kbd-shadows': hexToRgb(colors.gray[900]),
'--tw-prose-code': colors.gray[900],

@@ -1008,2 +1080,4 @@ '--tw-prose-pre-code': colors.gray[200],

'--tw-prose-invert-captions': colors.gray[400],
'--tw-prose-invert-kbd': colors.white,
'--tw-prose-invert-kbd-shadows': hexToRgb(colors.white),
'--tw-prose-invert-code': colors.white,

@@ -1030,2 +1104,4 @@ '--tw-prose-invert-pre-code': colors.gray[300],

'--tw-prose-captions': colors.zinc[500],
'--tw-prose-kbd': colors.zinc[900],
'--tw-prose-kbd-shadows': hexToRgb(colors.zinc[900]),
'--tw-prose-code': colors.zinc[900],

@@ -1047,2 +1123,4 @@ '--tw-prose-pre-code': colors.zinc[200],

'--tw-prose-invert-captions': colors.zinc[400],
'--tw-prose-invert-kbd': colors.white,
'--tw-prose-invert-kbd-shadows': hexToRgb(colors.white),
'--tw-prose-invert-code': colors.white,

@@ -1069,2 +1147,4 @@ '--tw-prose-invert-pre-code': colors.zinc[300],

'--tw-prose-captions': colors.neutral[500],
'--tw-prose-kbd': colors.neutral[900],
'--tw-prose-kbd-shadows': hexToRgb(colors.neutral[900]),
'--tw-prose-code': colors.neutral[900],

@@ -1086,2 +1166,4 @@ '--tw-prose-pre-code': colors.neutral[200],

'--tw-prose-invert-captions': colors.neutral[400],
'--tw-prose-invert-kbd': colors.white,
'--tw-prose-invert-kbd-shadows': hexToRgb(colors.white),
'--tw-prose-invert-code': colors.white,

@@ -1108,2 +1190,4 @@ '--tw-prose-invert-pre-code': colors.neutral[300],

'--tw-prose-captions': colors.stone[500],
'--tw-prose-kbd': colors.stone[900],
'--tw-prose-kbd-shadows': hexToRgb(colors.stone[900]),
'--tw-prose-code': colors.stone[900],

@@ -1125,2 +1209,4 @@ '--tw-prose-pre-code': colors.stone[200],

'--tw-prose-invert-captions': colors.stone[400],
'--tw-prose-invert-kbd': colors.white,
'--tw-prose-invert-kbd-shadows': hexToRgb(colors.white),
'--tw-prose-invert-code': colors.white,

@@ -1254,2 +1340,26 @@ '--tw-prose-invert-pre-code': colors.stone[300],

},
// Invert (for dark mode)
invert: {
css: {
'--tw-prose-body': 'var(--tw-prose-invert-body)',
'--tw-prose-headings': 'var(--tw-prose-invert-headings)',
'--tw-prose-lead': 'var(--tw-prose-invert-lead)',
'--tw-prose-links': 'var(--tw-prose-invert-links)',
'--tw-prose-bold': 'var(--tw-prose-invert-bold)',
'--tw-prose-counters': 'var(--tw-prose-invert-counters)',
'--tw-prose-bullets': 'var(--tw-prose-invert-bullets)',
'--tw-prose-hr': 'var(--tw-prose-invert-hr)',
'--tw-prose-quotes': 'var(--tw-prose-invert-quotes)',
'--tw-prose-quote-borders': 'var(--tw-prose-invert-quote-borders)',
'--tw-prose-captions': 'var(--tw-prose-invert-captions)',
'--tw-prose-kbd': 'var(--tw-prose-invert-kbd)',
'--tw-prose-kbd-shadows': 'var(--tw-prose-invert-kbd-shadows)',
'--tw-prose-code': 'var(--tw-prose-invert-code)',
'--tw-prose-pre-code': 'var(--tw-prose-invert-pre-code)',
'--tw-prose-pre-bg': 'var(--tw-prose-invert-pre-bg)',
'--tw-prose-th-borders': 'var(--tw-prose-invert-th-borders)',
'--tw-prose-td-borders': 'var(--tw-prose-invert-td-borders)',
},
},
}

@@ -1263,2 +1373,3 @@

maxWidth: '65ch',
p: {}, // Required to maintain correct order when merging
'[class~="lead"]': {

@@ -1375,8 +1486,13 @@ color: 'var(--tw-prose-lead)',

},
// TODO: Figure out how to not need these, it's a merging issue
img: {},
'figure > *': {},
figcaption: {
color: 'var(--tw-prose-captions)',
img: {}, // Required to maintain correct order when merging
picture: {
display: 'block',
},
kbd: {
fontWeight: '500',
fontFamily: 'inherit',
color: 'var(--tw-prose-kbd)',
boxShadow:
'0 0 0 1px rgb(var(--tw-prose-kbd-shadows) / 10%), 0 3px 0 rgb(var(--tw-prose-kbd-shadows) / 10%)',
},
code: {

@@ -1469,2 +1585,6 @@ color: 'var(--tw-prose-code)',

},
'figure > *': {}, // Required to maintain correct order when merging
figcaption: {
color: 'var(--tw-prose-captions)',
},
},

@@ -1471,0 +1591,0 @@ defaultModifiers.gray.css,

const isPlainObject = require('lodash.isplainobject')
const parser = require('postcss-selector-parser')
const parseSelector = parser()
module.exports = {

@@ -7,2 +10,54 @@ isUsableColor(color, values) {

},
/**
* @param {string} selector
*/
commonTrailingPseudos(selector) {
let ast = parseSelector.astSync(selector)
/** @type {import('postcss-selector-parser').Pseudo[][]} */
let matrix = []
// Put the pseudo elements in reverse order in a sparse, column-major 2D array
for (let [i, sel] of ast.nodes.entries()) {
for (const [j, child] of [...sel.nodes].reverse().entries()) {
// We only care about pseudo elements
if (child.type !== 'pseudo' || !child.value.startsWith('::')) {
break
}
matrix[j] = matrix[j] || []
matrix[j][i] = child
}
}
let trailingPseudos = parser.selector()
// At this point the pseudo elements are in a column-major 2D array
// This means each row contains one "column" of pseudo elements from each selector
// We can compare all the pseudo elements in a row to see if they are the same
for (const pseudos of matrix) {
// It's a sparse 2D array so there are going to be holes in the rows
// We skip those
if (!pseudos) {
continue
}
let values = new Set([...pseudos.map((p) => p.value)])
// The pseudo elements are not the same
if (values.size > 1) {
break
}
pseudos.forEach((pseudo) => pseudo.remove())
trailingPseudos.prepend(pseudos[0])
}
if (trailingPseudos.nodes.length) {
return [trailingPseudos.toString(), ast.toString()]
}
return [null, selector]
},
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc