Skip to content

Instantly share code, notes, and snippets.

@NeraSnow
Created December 14, 2023 00:32
Show Gist options
  • Save NeraSnow/7c82f3ea3ecb4845ed4102af4a1e4917 to your computer and use it in GitHub Desktop.
Save NeraSnow/7c82f3ea3ecb4845ed4102af4a1e4917 to your computer and use it in GitHub Desktop.
Tweaking CSS files of SICP for Ebook Readers

Introduction

We have this wonderful SICP (Structure and Interpretation of Computer Programs) Ebook Project. But the epub ebook file created is catered for colored screens. Some of the default color schemes are not great for Ebook readers. I did the following things to make the epub version of the SICP more suitable for Ebook readers.

I am using Calibre to edit the epub file. I am satisfied with the result. Please let me know if there is anything that should also be changed.

Changes

prettify.css

/* SPAN elements with the classes below are added by prettyprint. */
/* Modified for Kindle */
.pln { color: black }  /* plain text */

/* Modified for Kindle */
@media screen {
  .str { color: black }  /* string content */
  .kwd { color: black; font-weight: normal }  /* a keyword */
  .com { color: black; }  /* a comment */
  var .com, .com var { font-style: italic }  /* a slanted comment */
  .typ { color: black }  /* a type name */
  .lit { color: black }  /* a literal value */
  /* punctuation, lisp open bracket, lisp close bracket */
  .pun { color: black }
  .opn, .clo { color: black }
  .err { color: black }  /* 'error' keyword (A.R) */
  .tag { color: black }  /* a markup tag name */
  .atn { color: black }  /* a markup attribute name */
  .atv { color: black }  /* a markup attribute value */
  .dec, .var { color: black }  /* a declaration; a variable name */
  .fun { color: black }  /* a function name */
}

style.css

html {
  font-family: "Linux Libertine O", serif;
  font-size: 100%; /* 100% for epub */
  color: #000000; /* modified for Kindle */
  line-height: 130%;
  /* 'liga' turns on ligatures, 'ss06' picks alternate ampersand */
  -moz-font-feature-settings: "liga" 1, "ss06";
  -ms-font-feature-settings: "liga" 1, "ss06";
  -webkit-font-feature-settings: "liga", "ss06";
  -o-font-feature-settings: "liga", "ss06";
  font-feature-settings: "liga", "ss06";
}
body {
  background-color: #ffffff; /* Modified for Kindle */
  margin: 0;
  position: relative;
}
.chapnum {
  display: inline-block;
  font-weight: normal;
  font-size: 6.7em;
  color: black; /* Modified for Kindle */
  height: 1ex;
  margin-top: 0.3ex;
  margin-bottom: 0.5ex;
}
.secnum {
  display: inline-block;
  color: #000000; /* Modified for Kindle */
  margin-right: 0.8em;
  vertical-align: top;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment