![]() |
#1 |
Member
![]() Posts: 15
Karma: 10
Join Date: Sep 2015
Device: Kindle Voyage
|
a little problem with code formatting
Hi sigil fans, I'm having a little dumb question here and looking for some slutions. I'm creating a book about html, and I need to show some code examples in my book, like <p style="background-color:yellow;">XXXX</p>. the problem is sigil will just treat them as general code and execute them, so I can only see “XXXX” in book view with yellow background. I tried to wrap them with code tag, like:
<code> <p style="background-color:yellow;">XXXX</p> </code> but this does not work. For now I should add some random notations between tags so Sigil won't execute them. Does anyone have some better ideas? ![]() |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,365
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
If you paste html code into book view, it will do the escaping necessary to render them. In code view you would have to use entities manually to represent the the < and > characters. Either way, you will have to use styles to do any colors and/or highlighting.
There is no handy-dandy tag to present code in xhtml (in all renderers). Those are typically forum or blog (or other rendering engine) plugins that allow posts to present code in an easy manner (on THAT particular platform). |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
1. In your .xhtml file write: Code:
<div class="code"> <pre> <p class="background">XXX</p> </pre> </div> Code:
.code { font-family: "monospace"; /* This wouldn't be necessary if you use the <pre> tag but... */ background: #eee; font-size: 1.2em; /* change the font size if you wish */ font-weight: bold; /* change this to normal if you wish */ padding: 0 1em; border: 1px dotted; } Below I attach the respective epub so you can understand better all the things. Regards Rubén Last edited by RbnJrg; 11-30-2015 at 11:25 AM. |
|
![]() |
![]() |
![]() |
#4 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
I used Freebits for this purpose:
http://www.freebits.co.uk/convert-ht...e-to-text.html (I didn't know about pasting into Book View! Indeed, it was probably before Hitch turned me on to epub.) |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PDF to MOBI formatting source code | redhead_cz | Conversion | 2 | 02-10-2013 04:33 PM |
Formatting for documentation source code | Halo | Development | 1 | 08-14-2011 09:39 PM |
Help formatting Source Code | frios | ePub | 3 | 07-15-2011 08:06 AM |
Formatting, code, simple help needed | panda6855 | Sigil | 43 | 01-13-2011 06:37 PM |
would someone kindly explain this formatting code | Book | IMP | 2 | 07-03-2009 10:53 PM |