View Single Post
Old 11-30-2015, 11:17 AM   #3
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,830
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by tiandijie View Post
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?
Do the following:

1. In your .xhtml file write:

Code:
<div class="code">
    <pre>
         &lt;p class="background"&gt;XXX&lt;/p&gt;
    </pre>
</div>
2. In your .css file write:

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;
}
This is how it looks in Sigil:

Click image for larger version

Name:	Image1.png
Views:	168
Size:	71.4 KB
ID:	144194

Below I attach the respective epub so you can understand better all the things.

Regards
Rubén
Attached Files
File Type: epub Code Example.epub (2.2 KB, 127 views)

Last edited by RbnJrg; 11-30-2015 at 11:25 AM.
RbnJrg is offline   Reply With Quote