-
-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose Markdown content styles (#1049)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
- Loading branch information
Showing
5 changed files
with
126 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/starlight': patch | ||
--- | ||
|
||
Expose Markdown content styles in `@astrojs/starlight/style/markdown.css` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,6 @@ | ||
--- | ||
import type { Props } from '../props'; | ||
import '../style/markdown.css'; | ||
--- | ||
|
||
<div class="content"><slot /></div> | ||
|
||
<style> | ||
.content | ||
:global( | ||
:not(a, strong, em, del, span, input, code) | ||
+ :not(a, strong, em, del, span, input, code, :where(.not-content *)) | ||
) { | ||
margin-top: 1.5rem; | ||
} | ||
|
||
/* Headings after non-headings have more spacing. */ | ||
.content | ||
:global( | ||
:not(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) | ||
) { | ||
margin-top: 2.5rem; | ||
} | ||
|
||
.content :global(li + li:not(:where(.not-content *))), | ||
.content :global(dt + dt:not(:where(.not-content *))), | ||
.content :global(dt + dd:not(:where(.not-content *))), | ||
.content :global(dd + dd:not(:where(.not-content *))) { | ||
margin-top: 0.25rem; | ||
} | ||
|
||
.content | ||
:global( | ||
li > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) | ||
) { | ||
margin-bottom: 1.25rem; | ||
} | ||
|
||
.content :global(dt:not(:where(.not-content *))) { | ||
font-weight: 700; | ||
} | ||
.content :global(dd:not(:where(.not-content *))) { | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.content :global(:is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *))) { | ||
color: var(--sl-color-white); | ||
line-height: var(--sl-line-height-headings); | ||
font-weight: 600; | ||
} | ||
|
||
.content :global(:is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *))) { | ||
display: block; | ||
max-width: 100%; | ||
height: auto; | ||
} | ||
|
||
.content :global(h1:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h1); | ||
} | ||
.content :global(h2:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h2); | ||
} | ||
.content :global(h3:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h3); | ||
} | ||
.content :global(h4:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h4); | ||
} | ||
.content :global(h5:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h5); | ||
} | ||
.content :global(h6:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h6); | ||
} | ||
|
||
.content :global(a:not(:where(.not-content *))) { | ||
color: var(--sl-color-text-accent); | ||
} | ||
.content :global(a:hover:not(:where(.not-content *))) { | ||
color: var(--sl-color-white); | ||
} | ||
|
||
.content :global(code:not(:where(.not-content *))) { | ||
background-color: var(--sl-color-bg-inline-code); | ||
margin-block: -0.125rem; | ||
padding: 0.125rem 0.375rem; | ||
font-size: var(--sl-text-code-sm); | ||
} | ||
.content :global(:is(h1, h2, h3, h4, h5, h6) code) { | ||
font-size: inherit; | ||
} | ||
|
||
.content :global(pre:not(:where(.not-content *))) { | ||
border: 1px solid var(--sl-color-gray-5); | ||
padding: 0.75rem 1rem; | ||
font-size: var(--sl-text-code); | ||
tab-size: 2; | ||
} | ||
|
||
.content :global(pre code:not(:where(.not-content *))) { | ||
all: unset; | ||
font-family: var(--__sl-font-mono); | ||
} | ||
|
||
.content :global(blockquote:not(:where(.not-content *))) { | ||
border-inline-start: 1px solid var(--sl-color-gray-5); | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.content :global(table:not(:where(.not-content *))) { | ||
display: block; | ||
overflow: auto; | ||
border-collapse: collapse; | ||
} | ||
.content :global(tr:nth-child(2n):not(:where(.not-content *))) { | ||
background-color: var(--sl-color-gray-7, var(--sl-color-gray-6)); | ||
} | ||
.content :global(:is(th, td):not(:where(.not-content *))) { | ||
border: 1px solid var(--sl-color-hairline-light); | ||
padding: 0.375rem 0.8125rem; | ||
} | ||
|
||
.content :global(hr:not(:where(.not-content *))) { | ||
border: 0; | ||
border-bottom: 1px solid var(--sl-color-hairline); | ||
} | ||
</style> | ||
<div class="sl-markdown-content"><slot /></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
.sl-markdown-content | ||
:not(a, strong, em, del, span, input, code) | ||
+ :not(a, strong, em, del, span, input, code, :where(.not-content *)) { | ||
margin-top: 1.5rem; | ||
} | ||
|
||
/* Headings after non-headings have more spacing. */ | ||
.sl-markdown-content | ||
:not(h1, h2, h3, h4, h5, h6) | ||
+ :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) { | ||
margin-top: 2.5rem; | ||
} | ||
|
||
.sl-markdown-content li + li:not(:where(.not-content *)), | ||
.sl-markdown-content dt + dt:not(:where(.not-content *)), | ||
.sl-markdown-content dt + dd:not(:where(.not-content *)), | ||
.sl-markdown-content dd + dd:not(:where(.not-content *)) { | ||
margin-top: 0.25rem; | ||
} | ||
|
||
.sl-markdown-content | ||
li | ||
> :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) { | ||
margin-bottom: 1.25rem; | ||
} | ||
|
||
.sl-markdown-content dt:not(:where(.not-content *)) { | ||
font-weight: 700; | ||
} | ||
.sl-markdown-content dd:not(:where(.not-content *)) { | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.sl-markdown-content :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) { | ||
color: var(--sl-color-white); | ||
line-height: var(--sl-line-height-headings); | ||
font-weight: 600; | ||
} | ||
|
||
.sl-markdown-content :is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *)) { | ||
display: block; | ||
max-width: 100%; | ||
height: auto; | ||
} | ||
|
||
.sl-markdown-content h1:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h1); | ||
} | ||
.sl-markdown-content h2:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h2); | ||
} | ||
.sl-markdown-content h3:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h3); | ||
} | ||
.sl-markdown-content h4:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h4); | ||
} | ||
.sl-markdown-content h5:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h5); | ||
} | ||
.sl-markdown-content h6:not(:where(.not-content *)) { | ||
font-size: var(--sl-text-h6); | ||
} | ||
|
||
.sl-markdown-content a:not(:where(.not-content *)) { | ||
color: var(--sl-color-text-accent); | ||
} | ||
.sl-markdown-content a:hover:not(:where(.not-content *)) { | ||
color: var(--sl-color-white); | ||
} | ||
|
||
.sl-markdown-content code:not(:where(.not-content *)) { | ||
background-color: var(--sl-color-bg-inline-code); | ||
margin-block: -0.125rem; | ||
padding: 0.125rem 0.375rem; | ||
font-size: var(--sl-text-code-sm); | ||
} | ||
.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) code { | ||
font-size: inherit; | ||
} | ||
|
||
.sl-markdown-content pre:not(:where(.not-content *)) { | ||
border: 1px solid var(--sl-color-gray-5); | ||
padding: 0.75rem 1rem; | ||
font-size: var(--sl-text-code); | ||
tab-size: 2; | ||
} | ||
|
||
.sl-markdown-content pre code:not(:where(.not-content *)) { | ||
all: unset; | ||
font-family: var(--__sl-font-mono); | ||
} | ||
|
||
.sl-markdown-content blockquote:not(:where(.not-content *)) { | ||
border-inline-start: 1px solid var(--sl-color-gray-5); | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.sl-markdown-content table:not(:where(.not-content *)) { | ||
display: block; | ||
overflow: auto; | ||
border-collapse: collapse; | ||
} | ||
.sl-markdown-content tr:nth-child(2n):not(:where(.not-content *)) { | ||
background-color: var(--sl-color-gray-7, var(--sl-color-gray-6)); | ||
} | ||
.sl-markdown-content :is(th, td):not(:where(.not-content *)) { | ||
border: 1px solid var(--sl-color-hairline-light); | ||
padding: 0.375rem 0.8125rem; | ||
} | ||
|
||
.sl-markdown-content hr:not(:where(.not-content *)) { | ||
border: 0; | ||
border-bottom: 1px solid var(--sl-color-hairline); | ||
} |