Answers.Body: <p>I found the correct CSS to include, which is dependent from the way <a href="https://pandoc.org" rel="nofollow noreferrer">pandoc</a> produces the html:</p>
  <pre><code>&lt;style&gt;pre &gt; code.sourceCode { white-space: pre-wrap !important; }&lt;/style&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-14T16:14:10.143Z
Answers.Text: very interesting; by the way it looks like the Amazon supported CSS does NOT include the white-space pre-wrap attribute. https://kdp.amazon.com/en_US/help/topic/GB5GDY7WAJDN9GFK
  
  Occasionally this Kindle reference is wrong though. I'd be very curious whether it works on Kindle devices or the Kindle app.
Answers.UserDisplayName: idiotprogrammer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-14T12:32:28.027Z
Answers.LastActivityDate: 2022-08-14T12:32:28.027Z
Answers.UserDisplayName: PlasmaBinturong
Body: <p>I am trying to build an ebook from a programming tutorial (markdown):</p>
  <p>it contains many code blocks with comments; the comment lines are too long for the width of my Kobo H2O v2 reader, so I can't read the end...</p>
  <p>I tried adding a <a href="https://wiki.mobileread.com/wiki/EPUB#General" rel="nofollow noreferrer">CSS style</a> for wrapping:</p>
  <pre><code>&lt;style&gt;pre code { white-space: pre-wrap !important; }&lt;/style&gt;
  </code></pre>
  <ul>
  <li><p>It makes no difference to the Kobo default reader (nickel)...</p>
  </li>
  <li><p>However, the <code>ebook-viewer</code> command from calibre detects it and wraps them (instead of creating an horizontal scroll bar).</p>
  </li>
  <li><p>Also, inside Koreader, all exceeding lines are wrapped, no matter what CSS I add.</p>
  </li>
  </ul>
  <p><em>How do I make the default Kobo reader automatically wrap <code>pre</code> lines, without changing the source markdown?</em></p>
  <p>Here is a <a href="https://ebooks.stackexchange.com/q/7503/19485">similar unanswered question</a>.</p>
  
Tags: <kobo><css><formatting>
Title: How to wrap long lines inside 'pre code' environments, for Kobo
UserDisplayName: PlasmaBinturong
ThreadText: # How to wrap long lines inside 'pre code' environments, for Kobo
  
  (Asked by: username_0 on 2022-08-14)
  
  I am trying to build an ebook from a programming tutorial (markdown):
  it contains many code blocks with comments; the comment lines are too long for the width of my Kobo H2O v2 reader, so I can't read the end...
  I tried adding a CSS style for wrapping:
  
  
  
  It makes no difference to the Kobo default reader (nickel)...
  
  However, the ebook-viewer command from calibre detects it and wraps them (instead of creating an horizontal scroll bar).
  
  Also, inside Koreader, all exceeding lines are wrapped, no matter what CSS I add.
  
  
  How do I make the default Kobo reader automatically wrap pre lines, without changing the source markdown?
  Here is a similar unanswered question.
  
  **Tags:** kobo, css, formatting
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-08-14. Score: 1 | Accepted answer
  
  I found the correct CSS to include, which is dependent from the way pandoc produces the html:
  
  > **Comments:**
  > **username_1**: very interesting; by the way it looks like the Amazon supported CSS does NOT include the white-space pre-wrap attribute. https://kdp.amazon.com/en_US/help/topic/GB5GDY7WAJDN9GFK  Occasionally this Kindle reference is wrong though. I'd be very curious whether it works on Kindle devices or the Kindle app.  
  
  ---
  
  