Answers.Body: <p>If you want to stick with EPUB, you can save space by giving each tone a class with a short name and defining the class's color in the CSS. So the example you gave would look something like this:</p>
  
  <pre><code>&lt;span class="a"&gt; 今 &lt;/span&gt;
  </code></pre>
  
  <p>The CSS file, named something like stylesheet.css, would define the class like this:</p>
  
  <pre><code>span.a {
      color: #64B4FF
  }
  </code></pre>
  
  <p>You'd need to add a link to the stylesheet in the head element of each HTML file like this:</p>
  
  <pre><code>&lt;link href="stylesheet.css" type="text/css" rel="stylesheet"/&gt;
  </code></pre>
  
  <p>The path in href is relative, and this example assumes stylesheet.css is in the same directory as the HTML file.</p>
  
  <p>I don't know if this approach will save enough space to speed up highlighting and dictionary lookups, but it's something to try.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-15T14:44:11.193Z
Answers.LastActivityDate: 2016-02-15T14:44:11.193Z
Answers.UserDisplayName: thinkulum
Body: <p>For the purposes of learning Chinese, I want to write every character in a short novel in a colour that corresponds to its tone (pronunciation thing). The book is an epub, and I've been doing the html inside it like this: </p>
  
  <pre><code>&lt;span style="color:#64B4FF"&gt; 今 &lt;/span&gt;
  </code></pre>
  
  <p>This works to display the colours correctly, but the file is now so big and unwieldy that highlighting and dictionary lookup has become unacceptably slow. Is there a more efficient way to do this, or a better file format to use? I don't want to convert to pdf because then I would lose the ability to do dictionary lookups.</p>
  
  <p>Possibly relevant info: the characters are in utf-8 right now, there are only five possible colours, and I'm using moon+ reader on Android with the goldendict dictionary.</p>
  
Tags: <html>
Title: Efficient way to colour code text?
UserDisplayName: Xiao Laoshu
ThreadText: # Efficient way to colour code text?
  
  (Asked by: username_0 on 2016-02-13)
  
  For the purposes of learning Chinese, I want to write every character in a short novel in a colour that corresponds to its tone (pronunciation thing). The book is an epub, and I've been doing the html inside it like this: 
   今 
  
  This works to display the colours correctly, but the file is now so big and unwieldy that highlighting and dictionary lookup has become unacceptably slow. Is there a more efficient way to do this, or a better file format to use? I don't want to convert to pdf because then I would lose the ability to do dictionary lookups.
  Possibly relevant info: the characters are in utf-8 right now, there are only five possible colours, and I'm using moon+ reader on Android with the goldendict dictionary.
  
  **Tags:** html
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-02-15. Score: 1
  
  If you want to stick with EPUB, you can save space by giving each tone a class with a short name and defining the class's color in the CSS. So the example you gave would look something like this:
   今 
  
  The CSS file, named something like stylesheet.css, would define the class like this:
  span.a {
      color: #64B4FF
  }
  
  You'd need to add a link to the stylesheet in the head element of each HTML file like this:
  
  
  The path in href is relative, and this example assumes stylesheet.css is in the same directory as the HTML file.
  I don't know if this approach will save enough space to speed up highlighting and dictionary lookups, but it's something to try.
  
  
  ---
  
  