Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 10-08-2017, 08:17 AM   #1
dom9
Junior Member
dom9 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2017
Device: Galaxy S8+
Code snippet misses line numbers and messes indentation up

Trying to convert the Swift 4.0 guide to read on paper.
The whole thing looks beautifully but the code snippets are off

The last random amount of line numbers isn't printed and the actual lines are always off indentation. Since the book is a programming book, it consists mostly of code snippets, so this small bug makes the whole things unprintable.

How do I fix this?

Here's an example snippet https://imgur.com/a/1TQ9G

PS: I am using the latest Calibre 3.9.0 on macOS High Sierra

Last edited by dom9; 10-08-2017 at 08:31 AM.
dom9 is offline   Reply With Quote
Old 10-08-2017, 01:01 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,558
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://www.mobileread.com/forums/sho...d.php?t=186697
kovidgoyal is offline   Reply With Quote
Advert
Old 10-08-2017, 04:31 PM   #3
dom9
Junior Member
dom9 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Oct 2017
Device: Galaxy S8+
Thank you for your reply, Kovid. Hope this will help:

1. eBook: https://swift.org/documentation/TheS...e(Swift4).epub
2. Calibre Log: https://pastebin.com/LVZmn3EW
3. Translated File: https://www.dropbox.com/s/bpamen9oht...0Inc_.pdf?dl=0
4. Issue: Random last lines of snippets of code lose indentation and numbering.
5. Changed from default options: Only fonts and font sizes. You can find all of em here: https://www.dropbox.com/s/wks19puodv...0opts.png?dl=0

Last edited by dom9; 10-08-2017 at 04:34 PM.
dom9 is offline   Reply With Quote
Old 10-09-2017, 12:09 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,558
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Nothing random about it, its basically caused by a hack the CSS in that book uses that breaks when font sizes are rescaled. You can either disable font size rescaling in the conversion or open up the book with the calibre editor and edit epub.css removing the rule:

Code:
/* fix for double-digit code listing numbers */
#conceptual_flow_with_tasks .code-lines li:nth-child(n+10) {
  text-indent: -6.55em;
}
Basically the CSS in that book uses a mixture of rem and em units for different things, that does not play well with font size rescaling.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pre-formatted code snippet renders badly CBSA Editor 19 02-25-2017 01:47 PM
Indentation in right aligned long line poems AlexBell ePub 25 07-13-2015 03:26 PM
How do I create first line paragraph indentation with Calibre? stutzj Calibre 4 01-21-2014 12:09 PM
Strange Code Replaces Numbers Gwaredd Conversion 1 07-23-2013 01:03 PM
[Suggestion] Change indentation to one letter per indentation level. John Peterson Development 1 10-22-2012 03:05 PM


All times are GMT -4. The time now is 08:07 AM.


MobileRead.com is a privately owned, operated and funded community.