Improve code blocks styling ()

* add highlight config for code highlighter

* add default pygment css "github"

* fix styles for code blocks

* remove dead html from margin note

*These don't appear to do anything?

* Fix scrolling in code block

* More CSS fixes for code blocks

* ignore generated scss files. Probably other generated files too

* Use scss to generate more powerful styles for code blocks

* Document new code blocks style option

Improve code blocks styling
This commit is contained in:
TuckerD 2021-08-03 16:18:19 -04:00 committed by GitHub
commit ba23674640
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 311 additions and 124 deletions

View file

@ -0,0 +1,12 @@
$ht-code-bgcolor: #282a36;
@import "syntax-dark.scss";
.highlight {
&::-webkit-scrollbar {
background: $ht-code-bgcolor;
}
&::-webkit-scrollbar-thumb {
background: scale-color($ht-code-bgcolor, $lightness: 23%, $saturation: -40%);
}
}

View file

@ -0,0 +1,12 @@
$ht-code-bgcolor: #dde2ff;
@import "syntax-light.scss";
.highlight {
&::-webkit-scrollbar {
background: $ht-code-bgcolor;
}
&::-webkit-scrollbar-thumb {
background: scale-color($ht-code-bgcolor, $lightness: -13%, $saturation: -80%);
}
}

332
assets/scss/hugo-tufte.scss Normal file
View file

@ -0,0 +1,332 @@
/* ------------------------------------------------------------------------ */
/* hugo-tufte.css */
/* Contains extensions to the original tufte.css styles to */
/* accomodate a blog-like site. */
/* ------------------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@351&display=swap');
/* When setting the primary font stack, apply it to the Pure grid units along */
/* with `html`, `button`, `input`, `select`, and `textarea`. Pure Grids use */
/* specific font stacks to ensure the greatest OS/browser compatibility. */
html, button, input, select, textarea, p, nav, section, article, header, footer, .pure-g [class *= "pure-u"] {
font-family: "et-book", -apple-system, "San Francisco", "Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Open Sans","Helvetica Neue", "Lucida Grand", sans-serif;
}
p {
text-align: justify;
}
code {
font-family: "Fira Code", Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 1.125rem;
line-height: 1.6;
}
$ht-code-border-radius: .4em;
.highlight {
width: 55%;
overflow-x: scroll;
border-radius: $ht-code-border-radius;
&>div.chroma>table.lntable{
margin: $ht-code-border-radius 0 $ht-code-border-radius 0;
& td:first-of-type {
& span:not(& span>span) {
padding: 0 .75em 0 .5em;
}
}
}
&>.chroma>code {
width: max-content;
margin-top: .5em;
margin-bottom: .5em;
margin-left: .5em;
&>span.hl{
margin-left: -.5em;
padding-left: .5em;
}
}
.chroma .hl {
// border-radius: $ht-code-border-radius / 2;
display: block;
}
&::-webkit-scrollbar {
border-radius: $ht-code-border-radius;
width: 10px;
height: 1rem;
}
&::-webkit-scrollbar-thumb {
border-radius: $ht-code-border-radius;
}
}
.highlight .lntable {
overflow: initial;
}
.highlight pre {
margin: 0;
}
.highlight pre code {
display: block;
font-size: 1rem;
}
.sidenote, .marginnote {
margin-right: -55%;
width: 45%;
}
/* ------------------------------------------------------------------------ */
/* Brand details, such as a sidebar or top display. */
/* ------------------------------------------------------------------------ */
header.brand{
margin-top: 0.5em;
}
/* Main brand title */
header.brand h1 {
margin: 0;
font-weight: 400;
color: rgba(65, 70, 75, 1);
}
header.brand h2 {
margin: 0;
padding-top: 0rem;
/*font-style: normal;*/
/*font-weight: 200;*/
color: rgba(100, 105, 110, 1);
}
header.brand hr {
text-align: left;
margin-left: 0;
width: 75%;
border-color: rgba(250, 250, 250, 0.25);
}
nav.menu ul {
list-style: none;
display: block;
/*text-align:center;*/
margin-top: 0.75rem;
padding: 0;
max-width: 45rem;
/* Width is the same as tufte.css body */
font-size: .9rem;
width: 87.5%;
}
nav.menu li {
display: inline-block;
margin-right: 1rem;
}
nav.menu li a {
text-decoration: none;
background: transparent;
color: rgba(65, 70, 75, 1);
letter-spacing: 0.05em;
text-transform: uppercase;
}
nav.menu li a:hover,
nav.menu li a:active,
nav.menu li a:focus {
background: inherit;
color: darkgray;
}
/* ------------------------------------------------------------------------ */
/* Generic content, such as the index list pages */
/* ------------------------------------------------------------------------ */
/* Content Title styling. This is mostly to avoid underlying links. */
h1.content-title {
/*max-width: 50rem;*/
}
h1.content-title a:link,
h1.content-title a:visited {
background: transparent;
text-decoration: none;
color: inherit;
}
h1.content-title a:hover,
h1.content-title a:focus {
color: darkgray;
}
/* Content meta-data such as author, publication date, etc. */
.content-meta {
display: block;
/*color: rgba(155, 155, 155, 1);*/
color: rgba(100, 105, 110, 1);
font-size: 1.1rem;
margin-top: 1em;
}
.content-meta .author {
/*color: rgb(90, 20, 55)*/
color: rgba(65, 70, 75, 1);
}
.post-avatar {
border-radius: 50px;
float: right;
margin-left: 1em;
}
/* ------------------------------------------------------------------------ */
/* Styling for listing pages. */
/* ------------------------------------------------------------------------ */
.list-page {
ul {
list-style-type: none;
margin: -0.25em;
width: 87.5%;
max-width: 45rem;
}
li {
margin: 0;
/*font-size: 95%;*/
}
}
.list-page
.list-date {
display: inline;
font-size: 0.75em;
/* padding-right: 2em; */
/* margin-right: 2em; */
}
/* Table of Contents */
.toc summary {
font-size: 1.5rem;
margin-bottom: -1.5rem;
padding-left: 0;
}
.toc {
/*float: right;*/
/*padding: 0rem 1rem 1rem 1rem;*/
/*margin-top: 1rem;*/
/*border-left: 1px solid #eee;*/
}
.toc ul {
list-style: none;
display: block;
/*margin-top: 0.75rem;*/
padding: 0;
width: 87.5%;
}
.toc li {
line-height: 0.5rem;
margin: 1rem;
}
table:not(.lntable) {
margin-top: 1em;
font-size: 1.4rem;
width: auto; /* making booktabs style tables the unstyled default in case someone uses Markdown styling */
/* margin: 0 auto; */
/* border-spacing: 0px; */
border-top: 2px solid #111;
border-bottom: 2px solid #111;
}
table:not(.lntable) th, table:not(.lntable) td{
font-size: 1.25rem;
line-height: 1.71428571;
}
table:not(.lntable) td {
padding-right: 0.75em;
}
table.lntable
{
td.lntd {
padding: 0em;
}
border-spacing: 0;
padding: 0;
}
/* Footer, but with a different name to avoid conflicts with tufte.css */
footer.page-footer{
padding-top: 1em;
margin-top: 3em;
color: #aaa;
width: 95%;
max-width: 45rem;
}
footer.page-footer p {
font-size: 1.2rem;
margin: 0em;
/* light font looked odd on chrome */
/*font-weight: lighter;*/
}
footer.page-footer a {
color: rgba(65, 70, 75, 1);
text-decoration: none;
background: transparent;
}
footer.page-footer hr {
text-align: left;
margin-left: 0;
width: 100%;
border-color: rgba(250, 250, 250, 0.25);
}
footer.page-footer ul.page-footer-menu {
list-style: none;
display: block;
/*text-align:center;*/
margin: 0;
padding: 0;
}
footer.page-footer ul.page-footer-menu li {
display: inline-block;
margin-right: 0.5rem;
font-size: 55%;
}
.copyright {
}
.copyright p {
font-size: 90%;
}
/* ------------------------------------------------------------------------ */
/* Post Archive. */
/* ------------------------------------------------------------------------ */
/* We utilize the html5 summary tags in order to create a post archive */
/* with built-in folding. */
details {
border-radius: 3px;
}
details summary {
vertical-align: top;
padding: .3em .5em;
outline: none;
/*color: rgba(65, 70, 75, 1);*/
}
details summary.year {
font-size: 1.5rem;
}
details[open] summary {
}

View file

@ -0,0 +1,91 @@
/* Dracula Theme v1.2.5
*
* https://github.com/zenorocha/dracula-theme
*
* Copyright 2016, All rights reserved
*
* Code licensed under the MIT license
* http://zenorocha.mit-license.org
*
* @author Rob G <wowmotty@gmail.com>
* @author Chris Bracco <chris@cbracco.me>
* @author Zeno Rocha <hi@zenorocha.com>
*/
.highlight .hl { background-color: scale-color($ht-code-bgcolor, $lightness: 32%, $saturation: -40%) }
.highlight { background: $ht-code-bgcolor; color: #f8f8f2 }
.highlight .c { color: #6272a4 } /* Comment */
.highlight .err { color: #f8f8f2 } /* Error */
.highlight .g { color: #f8f8f2 } /* Generic */
.highlight .k { color: #ff79c6 } /* Keyword */
.highlight .l { color: #f8f8f2 } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #ff79c6 } /* Operator */
.highlight .x { color: #f8f8f2 } /* Other */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #6272a4 } /* Comment.Hashbang */
.highlight .cm { color: #6272a4 } /* Comment.Multiline */
.highlight .cp { color: #ff79c6 } /* Comment.Preproc */
.highlight .cpf { color: #6272a4 } /* Comment.PreprocFile */
.highlight .c1 { color: #6272a4 } /* Comment.Single */
.highlight .cs { color: #6272a4 } /* Comment.Special */
.highlight .gd { color: #8b080b } /* Generic.Deleted */
.highlight .ge { color: #f8f8f2; text-decoration: underline } /* Generic.Emph */
.highlight .gr { color: #f8f8f2 } /* Generic.Error */
.highlight .gh { color: #f8f8f2; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #f8f8f2; font-weight: bold } /* Generic.Inserted */
.highlight .go { color: #44475a } /* Generic.Output */
.highlight .gp { color: #f8f8f2 } /* Generic.Prompt */
.highlight .gs { color: #f8f8f2 } /* Generic.Strong */
.highlight .gu { color: #f8f8f2; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #f8f8f2 } /* Generic.Traceback */
.highlight .kc { color: #ff79c6 } /* Keyword.Constant */
.highlight .kd { color: #8be9fd; font-style: italic } /* Keyword.Declaration */
.highlight .kn { color: #ff79c6 } /* Keyword.Namespace */
.highlight .kp { color: #ff79c6 } /* Keyword.Pseudo */
.highlight .kr { color: #ff79c6 } /* Keyword.Reserved */
.highlight .kt { color: #8be9fd } /* Keyword.Type */
.highlight .ld { color: #f8f8f2 } /* Literal.Date */
.highlight .m { color: #bd93f9 } /* Literal.Number */
.highlight .s { color: #f1fa8c } /* Literal.String */
.highlight .na { color: #50fa7b } /* Name.Attribute */
.highlight .nb { color: #8be9fd; font-style: italic } /* Name.Builtin */
.highlight .nc { color: #50fa7b } /* Name.Class */
.highlight .no { color: #f8f8f2 } /* Name.Constant */
.highlight .nd { color: #f8f8f2 } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #f8f8f2 } /* Name.Exception */
.highlight .nf { color: #50fa7b } /* Name.Function */
.highlight .nl { color: #8be9fd; font-style: italic } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #f8f8f2 } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #ff79c6 } /* Name.Tag */
.highlight .nv { color: #8be9fd; font-style: italic } /* Name.Variable */
.highlight .ow { color: #ff79c6 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #bd93f9 } /* Literal.Number.Bin */
.highlight .mf { color: #bd93f9 } /* Literal.Number.Float */
.highlight .mh { color: #bd93f9 } /* Literal.Number.Hex */
.highlight .mi { color: #bd93f9 } /* Literal.Number.Integer */
.highlight .mo { color: #bd93f9 } /* Literal.Number.Oct */
.highlight .sa { color: #f1fa8c } /* Literal.String.Affix */
.highlight .sb { color: #f1fa8c } /* Literal.String.Backtick */
.highlight .sc { color: #f1fa8c } /* Literal.String.Char */
.highlight .dl { color: #f1fa8c } /* Literal.String.Delimiter */
.highlight .sd { color: #f1fa8c } /* Literal.String.Doc */
.highlight .s2 { color: #f1fa8c } /* Literal.String.Double */
.highlight .se { color: #f1fa8c } /* Literal.String.Escape */
.highlight .sh { color: #f1fa8c } /* Literal.String.Heredoc */
.highlight .si { color: #f1fa8c } /* Literal.String.Interpol */
.highlight .sx { color: #f1fa8c } /* Literal.String.Other */
.highlight .sr { color: #f1fa8c } /* Literal.String.Regex */
.highlight .s1 { color: #f1fa8c } /* Literal.String.Single */
.highlight .ss { color: #f1fa8c } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2; font-style: italic } /* Name.Builtin.Pseudo */
.highlight .fm { color: #50fa7b } /* Name.Function.Magic */
.highlight .vc { color: #8be9fd; font-style: italic } /* Name.Variable.Class */
.highlight .vg { color: #8be9fd; font-style: italic } /* Name.Variable.Global */
.highlight .vi { color: #8be9fd; font-style: italic } /* Name.Variable.Instance */
.highlight .vm { color: #8be9fd; font-style: italic } /* Name.Variable.Magic */
.highlight .il { color: #bd93f9 } /* Literal.Number.Integer.Long */

View file

@ -0,0 +1,69 @@
.highlight .hl { background-color: #ffffd4 }
.highlight { background: $ht-code-bgcolor;}
.highlight .c { color: #6a737d } /* Comment */
.highlight .err { } /* Error */
.highlight .k { color: #d73a49 } /* Keyword */
.highlight .o { } /* Operator */
.highlight .ch { color: #6a737d } /* Comment.Hashbang */
.highlight .cm { color: #6a737d } /* Comment.Multiline */
.highlight .cp { color: #d73a49 } /* Comment.Preproc */
.highlight .cpf { color: #032f62 } /* Comment.PreprocFile */
.highlight .c1 { color: #6a737d } /* Comment.Single */
.highlight .cs { color: #6a737d } /* Comment.Special */
.highlight .gd { color: #b31d28; background-color: #ffeef0 } /* Generic.Deleted */
.highlight .ge { } /* Generic.Emph */
.highlight .gr { } /* Generic.Error */
.highlight .gh { color: #005cc5 } /* Generic.Heading */
.highlight .gi { color: #22863a; background-color: #f0fff4 } /* Generic.Inserted */
.highlight .go { } /* Generic.Output */
.highlight .gp { } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #6f42c1; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #005cc5 } /* Keyword.Constant */
.highlight .kd { color: #d73a49 } /* Keyword.Declaration */
.highlight .kn { color: #d73a49 } /* Keyword.Namespace */
.highlight .kp { color: #d73a49 } /* Keyword.Pseudo */
.highlight .kr { color: #d73a49 } /* Keyword.Reserved */
.highlight .kt { color: #d73a49 } /* Keyword.Type */
.highlight .m { color: #666666 } /* Literal.Number */
.highlight .s { color: #032f62 } /* Literal.String */
.highlight .na { } /* Name.Attribute */
.highlight .nb { color: #005cc5 } /* Name.Builtin */
.highlight .nc { color: #6f42c1 } /* Name.Class */
.highlight .no { color: #005cc5 } /* Name.Constant */
.highlight .nd { color: #6f42c1 } /* Name.Decorator */
.highlight .ni { color: #005cc5 } /* Name.Entity */
.highlight .ne { color: #005cc5 } /* Name.Exception */
.highlight .nf { color: #6f42c1 } /* Name.Function */
.highlight .nl { color: #005cc5 } /* Name.Label */
.highlight .nn { color: #6f42c1 } /* Name.Namespace */
.highlight .nt { color: #22863a } /* Name.Tag */
.highlight .nv { color: #24292e } /* Name.Variable */
.highlight .ow { color: #d73a49; } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #005cc5 } /* Literal.Number.Bin */
.highlight .mf { color: #005cc5 } /* Literal.Number.Float */
.highlight .mh { color: #005cc5 } /* Literal.Number.Hex */
.highlight .mi { color: #005cc5 } /* Literal.Number.Integer */
.highlight .mo { color: #005cc5 } /* Literal.Number.Oct */
.highlight .sa { color: #d73a49 } /* Literal.String.Affix */
.highlight .sb { color: #032f62 } /* Literal.String.Backtick */
.highlight .sc { color: #032f62 } /* Literal.String.Char */
.highlight .dl { color: #d73a49 } /* Literal.String.Delimiter */
.highlight .sd { color: #032f62 } /* Literal.String.Doc */
.highlight .s2 { color: #032f62 } /* Literal.String.Double */
.highlight .se { color: #032f62 } /* Literal.String.Escape */
.highlight .sh { color: #032f62 } /* Literal.String.Heredoc */
.highlight .si { color: #005cc5 } /* Literal.String.Interpol */
.highlight .sx { color: #032f62 } /* Literal.String.Other */
.highlight .sr { color: #032f62 } /* Literal.String.Regex */
.highlight .s1 { color: #032f62 } /* Literal.String.Single */
.highlight .ss { color: #005cc5 } /* Literal.String.Symbol */
.highlight .bp { color: #005cc5 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #005cc5 } /* Name.Function.Magic */
.highlight .vc { color: #24292e } /* Name.Variable.Class */
.highlight .vg { color: #24292e } /* Name.Variable.Global */
.highlight .vi { color: #24292e } /* Name.Variable.Instance */
.highlight .vm { color: #005cc5 } /* Name.Variable.Magic */
.highlight .il { color: #005cc5 } /* Literal.Number.Integer.Long */