Skip to content

Instantly share code, notes, and snippets.

@kellyredding
Last active August 29, 2015 14:04
Show Gist options
  • Save kellyredding/30ac3bbf4534e00b0c04 to your computer and use it in GitHub Desktop.
Save kellyredding/30ac3bbf4534e00b0c04 to your computer and use it in GitHub Desktop.
A coderay theme that mimicks GitHub syntax highlighting (not perfect, still a work-in-progress, but close...)
/* https://gist.github.com/kellyredding/30ac3bbf4534e00b0c04 */
code,
.CodeRay,
.CodeRay * {
box-sizing: border-box;
}
code,
.CodeRay .code pre {
font-family: Consolas,"Liberation Mono",Menlo,Courier,monospace;
color: #333;
}
.CodeRay .code pre {
font-size: 13px;
line-height: 19px;
overflow: auto;
}
code,
.CodeRay {
background-color: #f8f8f8;
border: 1px solid #ddd;
border-radius: 3px;
}
code {
margin: 0;
padding: 0;
}
code:before,
code:after {
content: "\00a0";
letter-spacing: -0.2em;
}
.CodeRay {
padding: 6px 10px;
margin: 15px 0;
}
.CodeRay pre {
margin: 0;
padding: 0;
}
div.CodeRay { }
span.CodeRay { white-space: pre; border: 0px; padding: 2px }
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
table.CodeRay td {
padding: 1em 0.5em;
vertical-align: top;
}
.CodeRay .line-numbers, .CodeRay .no {
background-color: #ECECEC;
color: #AAA;
text-align: right;
}
.CodeRay .line-numbers a {
color: #AAA;
}
.CodeRay .line-numbers tt { font-weight: bold }
.CodeRay .line-numbers .highlighted { color: red }
.CodeRay .line { display: block; float: left; width: 100%; }
.CodeRay span.line-numbers { padding: 0px 4px }
.CodeRay .code { width: 100% }
ol.CodeRay { font-size: 10pt }
ol.CodeRay li { white-space: pre }
.CodeRay .debug { color:white ! important; background:blue ! important; }
.CodeRay .annotation { color:#007 }
.CodeRay .attribute-name { color:teal }
.CodeRay .attribute-value { color:#700 }
.CodeRay .binary { color:#509; font-weight:bold }
.CodeRay .comment { color:#998; font-style: italic;}
.CodeRay .char { color:#04D }
.CodeRay .char .content { color:#04D }
.CodeRay .char .delimiter { color:#039 }
.CodeRay .class { color:#458; font-weight:bold }
.CodeRay .complex { color:#A08; font-weight:bold }
.CodeRay .constant { color:teal; }
.CodeRay .color { color:#0A0 }
.CodeRay .class-variable { color:#369 }
.CodeRay .decorator { color:#B0B; }
.CodeRay .definition { color:#099; font-weight:bold }
.CodeRay .directive { color:#088; font-weight:bold }
.CodeRay .delimiter { color:black }
.CodeRay .doc { color:#970 }
.CodeRay .doctype { color:#998; font-weight:bold }
.CodeRay .doc-string { color:#D42; font-weight:bold }
.CodeRay .escape { color:#666; font-weight:bold }
.CodeRay .entity { color:#800; font-weight:bold }
.CodeRay .error { color:#F00; background-color:#FAA }
.CodeRay .exception { color:#C00; font-weight:bold }
.CodeRay .filename { color:#099; }
.CodeRay .function { color:#900; font-weight:bold }
.CodeRay .global-variable { color: #0086b3 }
.CodeRay .hex { color:#058; font-weight:bold }
.CodeRay .integer { color:#099; }
.CodeRay .include { color:#B44; font-weight:bold }
.CodeRay .inline { color: black }
.CodeRay .inline .inline { background: #ccc }
.CodeRay .inline .inline .inline { background: #bbb }
.CodeRay .inline .inline-delimiter { color: #D14; }
.CodeRay .inline-delimiter { color: #D14; }
.CodeRay .important { color:#f00; }
.CodeRay .interpreted { color:#B2B; font-weight:bold }
.CodeRay .instance-variable { color:teal }
.CodeRay .label { color:#970; font-weight:bold }
.CodeRay .local-variable { color:#963 }
.CodeRay .octal { color:#40E; font-weight:bold }
.CodeRay .operator { }
.CodeRay .predefined-constant { color:teal; }
.CodeRay .predefined { color:#369; font-weight:bold }
.CodeRay .preprocessor { color:#579; }
.CodeRay .pseudo-class { color:#458; font-weight:bold }
.CodeRay .predefined-type { color:#074; font-weight:bold }
.CodeRay .reserved, .keyword { color:#000; font-weight:bold }
.CodeRay .key { color: #808; }
.CodeRay .key .delimiter { color: #606; }
.CodeRay .key .char { color: #80f; }
.CodeRay .value { color: #088; }
.CodeRay .regexp { color: #009926 }
.CodeRay .regexp .char { color: #009926 }
.CodeRay .regexp .content { color: #009926 }
.CodeRay .regexp .delimiter { color: #009926 }
.CodeRay .regexp .modifier { color: #009926 }
.CodeRay .regexp .function { color: #009926 }
.CodeRay .string { color: #D20; }
.CodeRay .string .string { }
.CodeRay .string .string .string { background-color:#ffd0d0 }
.CodeRay .string .content { color: #D14; }
.CodeRay .string .char { color: #D14; }
.CodeRay .string .delimiter { color: #D14; }
.CodeRay .shell { color:#D14 }
.CodeRay .shell .content { }
.CodeRay .shell .delimiter { color:#D14 }
.CodeRay .symbol { color:#990073 }
.CodeRay .symbol .content { color:#A60 }
.CodeRay .symbol .delimiter { color:#630 }
.CodeRay .tag { color:navy }
.CodeRay .tag-special { color:#D70; font-weight:bold }
.CodeRay .type { color:#339; font-weight:bold }
.CodeRay .variable { color:#036 }
.CodeRay .insert { background: #afa; }
.CodeRay .delete { background: #faa; }
.CodeRay .change { color: #aaf; background: #007; }
.CodeRay .head { color: #f8f; background: #505 }
.CodeRay .insert .insert { color: #080; font-weight:bold }
.CodeRay .delete .delete { color: #800; font-weight:bold }
.CodeRay .change .change { color: #66f; }
.CodeRay .head .head { color: #f4f; }
@kellyredding
Copy link
Author

(notes to self)

  • just verified on Ruby and HTML syntax so far

@kellyredding
Copy link
Author

(moar notes - fonts)

  • Consolas font kinda bugs me (ie the lowercase l)
  • Monaco is nicer, but might need to adjust font down to 12px to closer match gh sizing

@kellyredding
Copy link
Author

(moar font notes)

Here is some additional CSS for making the switch to Monaco go nice. Notes:

  • Monaco is a little "taller" than Consolas at the same font size - needs +1px addtional line height (or -1px font-size but I like it being "taller" in the pre elements)
  • the code font-size/line-height need to be -1px (assuming a "body copy" font-size/line-height of 14px/20px)
code,
.CodeRay .code pre {
  font-family: Monaco, Consolas,"Liberation Mono",Menlo,Courier,monospace;
}

code {
  font-size: 12px;
  line-height: 19px;
}
.CodeRay .code pre {
  font-size: 13px;
  line-height: 20px;
}

@kellyredding
Copy link
Author

(notes to self)

CSS and JSON is off a bit (due to limitations in coderay assigned classes):

  • Coderay assigns just a generic "key" and "value" to both CSS and JSON key: value statements
  • "key"s are set to #808 (purple) for both
  • "value"s are set based on their type (string, etc) but it differs from how GitHub does it

All of this is just FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment