// My GLORIOUS theme for rendered Markdown documents (But may come in handy for // other projects? Who knows!). Integrated with my colorscheme generators, best // paired with my very own syntax highlighting theme. Based on // sindresorhus/github-markdown-css[1] and primer/css[2]. By the way, here[3] // is the first ever public version of the Markdown styles. Also, GitLab's // stylesheet can be found here[4], it supports way more syntactical features. // // [1]: // [2]: // [3]: // [4]: // // User-Agent stylesheets (): // Firefox: // Chromium: @use 'sass:math'; @use 'sass:color'; // NOTE: GitHub uses an ancient version of normalize.css: // @use '../node_modules/normalize.css/normalize.css'; @use '../../../colorschemes/out/_colorscheme.scss'; //////////////////////////////////////////////////////////////////////////////// // CONFIGURATION CONSTANTS AND FUNCTIONS //////////////////////////////////////////////////////////////////////////////// // $font-default: 'Ubuntu', sans-serif; $font-monospace: 'Ubuntu Mono', monospace; // https://github.com/primer/css/blob/63764f7edd59c5f4949c91e5373471aa8b0d4865/src/support/variables/typography.scss#L29-L32 $line-height-headings: 1.25; $line-height-code-blocks: 1.3; $line-height-default: 1.5; // $font-size-default: 16px; // $border-radius: 4px; @function border($width: 1px, $style: solid, $color: colorscheme.$base-02) { @return $width $style $color; } $paragraph-spacing: 1em; //////////////////////////////////////////////////////////////////////////////// // MIXINS AND FUNCTIONS //////////////////////////////////////////////////////////////////////////////// @mixin clearfix { &::after, &::before { display: table; content: ''; } &::after { clear: both; } } @mixin cancel-out-child-margins { & > :first-child { margin-top: 0 !important; } & > :last-child { margin-bottom: 0 !important; } } //////////////////////////////////////////////////////////////////////////////// // BASE STYLES // // //////////////////////////////////////////////////////////////////////////////// // * { box-sizing: border-box; } // // body { color: colorscheme.$fg; background-color: colorscheme.$bg; font-family: $font-default; font-size: $font-size-default; line-height: $line-height-default; word-wrap: break-word; $tab-size: 4; -moz-tab-size: $tab-size; -o-tab-size: $tab-size; tab-size: $tab-size; &::-moz-selection, &::selection, & ::-moz-selection, & ::selection { color: colorscheme.$selection-fg; background-color: colorscheme.$selection-bg; } } // Also called `.markdown-body` by GitHub. article { min-width: 200px; max-width: 960px; margin: 0 auto; padding: 32px; @media (max-width: 768px - 1px) { padding: 24px; } @include clearfix(); @include cancel-out-child-margins(); } // // .octicon { display: inline-block; overflow: visible !important; // Not sure about this. vertical-align: text-bottom; fill: currentColor; } // a { color: colorscheme.$base-0D; text-decoration: none; &:hover, &:focus, &:active { text-decoration: underline; } // &:not([href]) { color: unset; text-decoration: none; } } // // hr { margin-top: $paragraph-spacing * 1.5; margin-bottom: $paragraph-spacing * 1.5; border: border($width: 0.2em); @include clearfix(); } // Set up paragraph margins for paragraphs themselves and other elements that // will appear at the top level. // dl, details, table, blockquote, ul, ol, pre, p { margin-top: $paragraph-spacing; margin-bottom: $paragraph-spacing; } // blockquote { margin-left: 0; margin-right: 0; padding-left: 1em; border-left: border($width: 0.25em); @include cancel-out-child-margins(); } // summary { cursor: pointer; } // img { max-width: 100%; // Fixes manually specified widths for images. box-sizing: content-box; background-color: colorscheme.$bg; &[align='left'], &[align='right'] { margin: 0.5em 1.25em; } &[align='left'] { margin-left: 0; } &[align='right'] { margin-right: 0; } } ins, del { text-decoration: none; } ins { color: colorscheme.$base-0B; } del { color: colorscheme.$base-08; } mark { background-color: colorscheme.$base-0A; color: colorscheme.$bg; } //////////////////////////////////////////////////////////////////////////////// // HEADINGS // //////////////////////////////////////////////////////////////////////////////// // h1, h2, h3, h4, h5, h6 { margin-top: $paragraph-spacing * 1.5; margin-bottom: $paragraph-spacing * 1; padding-bottom: 0.3em; border-bottom: border(); // Make the headers less bold, the default font-weight is 700. font-weight: 600; line-height: $line-height-headings; // .anchor { float: left; $size: 16px; $offset: 4px; padding-right: $offset; margin-left: -($size + $offset); // Undo the default styles for links. color: unset; &:hover { text-decoration: none; } &:focus { outline: none; } > * { visibility: hidden; vertical-align: middle; } } &:hover { .anchor > * { visibility: visible; } } @media (hover: none) { .anchor > * { visibility: visible; } } } h1 { font-size: 2em; } h2 { font-size: 1.5em; } h3 { font-size: 1.25em; } h4 { font-size: 1em; } h5 { font-size: 0.875em; } h6 { font-size: 0.85em; } //////////////////////////////////////////////////////////////////////////////// // CODE // // //////////////////////////////////////////////////////////////////////////////// code, kbd, samp, pre { font-family: $font-monospace; } // Inline code snippets. code { padding: 0.2em 0.3em; color: inherit; background-color: rgba(colorscheme.$base-03, 0.2); border-radius: $border-radius; } // Code blocks. pre { padding: 1em; overflow: auto; color: colorscheme.$fg; background-color: colorscheme.$bg; border: border(); border-radius: $border-radius; line-height: $line-height-code-blocks; word-wrap: normal; // Undo the highlighting of inline snippets. code { padding: unset; background-color: unset; border: unset; } } //////////////////////////////////////////////////////////////////////////////// // KEYBOARD SHORTCUTS // //////////////////////////////////////////////////////////////////////////////// kbd { display: inline-block; padding: 0.2em 0.3em; vertical-align: bottom; // The original stylesheet specifies both font-size and line-height in // pixels, but I want to do the same in relative units instead, so // recalculating everything proportionally. $orig-font-size: /* 11px */ 12px; $orig-line-height: 10px; $rel-font-size: math.div($orig-font-size, 16px) * 1em; $rel-line-height: math.div($orig-line-height, $orig-font-size); // This rule implicitly resets all inherited font-related properties. font: #{$rel-font-size}/#{$rel-line-height} #{$font-monospace}; $kbd-bg-color: if(colorscheme.$is-dark, colorscheme.$bg, colorscheme.$fg); $kbd-fg-color: if(colorscheme.$is-dark, colorscheme.$fg, colorscheme.$bg); color: $kbd-fg-color; background-color: color.change($kbd-bg-color, $lightness: 10%); border: border($width: 0.1em, $color: color.change($kbd-bg-color, $lightness: 5%)); border-bottom-width: 0.4em; border-radius: $border-radius; } //////////////////////////////////////////////////////////////////////////////// // TABLES // //////////////////////////////////////////////////////////////////////////////// // table { display: block; width: 100%; overflow: auto; // border-spacing: 0; border-collapse: collapse; // For browsers with support for `max-content`. Not sure what this pair of // rules does differently from just `width: 100%`. width: max-content; max-width: 100%; // img { background-color: transparent; } } th { font-weight: 600; } td, th { padding: 0.4em 0.75em; border: border(); } tr:nth-child(2n) { background-color: rgba(colorscheme.$base-02, 0.1); } //////////////////////////////////////////////////////////////////////////////// // LISTS // //////////////////////////////////////////////////////////////////////////////// // ol, ul { padding-left: 2em; // Disable the "paragraph" margins for nested lists. // & & { margin-top: 0; margin-bottom: 0; } } // li { margin-top: $paragraph-spacing * 0.25; margin-bottom: $paragraph-spacing * 0.25; } // dt { margin-top: $paragraph-spacing; font-weight: 600; font-style: italic; } // dd { margin-bottom: $paragraph-spacing; margin-left: 0; padding-left: 1em; } // Apparently not available in Primer? Had to copy from the extracted // production stylesheets. // // ul > li.task-list-item { list-style-type: none; > input[type='checkbox']:first-child { margin: 0 0.2em 0.25em -1.6em; vertical-align: middle; } } ////////////////////////////////////////////////////////////////////////////////