_code.scss 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Code
  2. //-------------------------------
  3. // Inline and block-level code snippets. Includes tweaks to syntax highlighted
  4. // snippets from Rouge and Gist embeds.
  5. code,
  6. pre {
  7. font-family: $serif;
  8. }
  9. // small code thingies
  10. code {
  11. padding: .25em .5em;
  12. font-size: .85em;
  13. // Could be mistaken for a link if the user choses a similar link-color, so better no colored inline code.
  14. // color: $code-color;
  15. background-color: var(--code-bg-color);
  16. // No border radius to prevent repaint on code scroll
  17. // border-radius: 3px;
  18. }
  19. code.highlighter-rouge {
  20. box-shadow: 0 1px 1px var(--shadow-color);
  21. }
  22. pre code {
  23. padding: 0;
  24. font-size: .75em;
  25. color: inherit;
  26. background-color: transparent;
  27. }
  28. figure, .figure {
  29. margin-left: -1rem;
  30. margin-right: -1rem;
  31. > *:first-child {
  32. padding: 1rem;
  33. background: var(--code-bg-color);
  34. }
  35. > figcaption, > .figcaption {
  36. font-size: smaller;
  37. color: #9a9a9a;
  38. text-align: center;
  39. font-style: italic;
  40. margin-top: 0.5rem;
  41. padding: 0 1rem;
  42. }
  43. }
  44. //http://www.minh.io/blog/2015/06/28/jekyll-line-numbers/
  45. //https://drewsilcock.co.uk/proper-linenumbers
  46. //https://sacha.me/articles/jekyll-rouge/#using-rouge-in-jekyll-3-on-github-pages
  47. // Rouge
  48. .highlight {
  49. margin-bottom: 1.5rem;
  50. font-size: .75em;
  51. // /* Prevent code linebreaks and allow side-scrolling (much better readability on mobile) */
  52. overflow-x: auto;
  53. -webkit-overflow-scrolling: touch;
  54. // /* Make code same width as regular text, and scroll the full page width on mobile */
  55. @include figure2();
  56. backface-visibility: hidden;
  57. box-shadow: 0 1px 2px var(--shadow-color);
  58. position: relative;
  59. &:before {
  60. position: absolute;
  61. top: 0;
  62. right: 0;
  63. padding: 0.5em;
  64. background-color: var(--code-border);
  65. content: "\e86f";
  66. font-family: "icomoon" !important;
  67. line-height: 1;
  68. text-transform: none;
  69. speak: none;
  70. box-shadow: 0 1px 2px var(--shadow-color);
  71. }
  72. pre {
  73. line-height: 1.6;
  74. padding: .5rem 0 .5rem .5rem;
  75. margin-bottom: 0;
  76. overflow-x: auto;
  77. }
  78. .lineno {
  79. display: inline-block; // Ensures the null space also isn't selectable
  80. padding-right: .25rem;
  81. color: var(--metadata-color);
  82. // Make sure numbers aren't selectable
  83. -webkit-user-select: none;
  84. -moz-user-select: none;
  85. user-select: none;
  86. }
  87. table {
  88. // resets down below
  89. width: 90%;
  90. background: transparent;
  91. box-shadow: none;
  92. margin-bottom: 0;
  93. font-size: inherit;
  94. td, th {
  95. padding: 0.25rem .5rem;
  96. }
  97. td:not(:first-child) {
  98. border-left: 0;
  99. }
  100. td.gutter {
  101. background: var(--code-border);
  102. box-shadow: 0 1px 2px var(--shadow-color);
  103. width: 6%;
  104. }
  105. td.code {
  106. position:relative;
  107. width: 90%;
  108. }
  109. }
  110. }
  111. @media (max-width: 48rem) {
  112. td.code:before {
  113. display: none;
  114. }
  115. }
  116. // Gist via GitHub Pages
  117. // .gist .gist-file {
  118. // font-family: Menlo, Monaco, "Courier New", monospace !important;
  119. // }
  120. // .gist .markdown-body {
  121. // padding: 15px;
  122. // }
  123. // .gist pre {
  124. // padding: 0;
  125. // background-color: transparent;
  126. // }
  127. // .gist .gist-file .gist-data {
  128. // font-size: .8rem !important;
  129. // line-height: 1.4;
  130. // }
  131. // .gist code {
  132. // padding: 0;
  133. // color: inherit;
  134. // background-color: transparent;
  135. // border-radius: 0;
  136. // }