MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Sigil (https://www.mobileread.com/forums/forumdisplay.php?f=203)
-   -   Possible to escape characters in CSS tags in Sigil? (https://www.mobileread.com/forums/showthread.php?t=171274)

GrannyGrump 03-06-2012 06:09 AM

Possible to escape characters in CSS tags in Sigil?
 
google found for me the possibility of using backslash escape character in CSS, but Sigil v 4.2 is throwing "not well-formed document" error. (on XP SP3 if that affects things)

Specifically, I'm using <h3> tags for chapter headings. I want to enter text in titles that will be picked up by the TOC generator. Some have a double-quote, and Calibre reader TOC cannot parse the unicode curly quotes - it displays black boxes. So I want to use straight quote marks.

Here's an example of what I'm trying to do:
Code:

<h3 title="IV. He shouts "NO" loudly" id="ch04">IV</h3>
If I use smart / curly quotes around NO, it is fine.
If I try to use straight quotes (alone or with backslash) I get "whitespace expected" error.

Is there such a thing as an escape character in epub tags, or is that wishful thinking?

Doitsu 03-06-2012 07:29 AM

Use the &quot; entity
 
This should work:
Code:

<h3 id="ch04" title="IV. He shouts &quot;NO&quot; loudly">IV</h3>

Rob Lister 03-06-2012 08:12 AM

Quote:

Originally Posted by grannyGrumpy (Post 1992890)
I want to enter text in titles that will be picked up by the TOC generator.

Off topic question: When you say 'picked up', what exactly does the Sigil TOC generator do with the title attribute in a header?

Timur 03-06-2012 09:34 AM

You can also type it like this:

Code:

<h3 title='IV. He shouts "NO" loudly' id="ch04">IV</h3>
When saving the file Sigil will convert it to the form given by Doitsu in a previous post.

DiapDealer 03-06-2012 09:51 AM

Quote:

Originally Posted by Rob Lister (Post 1992979)
Off topic question: When you say 'picked up', what exactly does the Sigil TOC generator do with the title attribute in a header?

It uses the title attribute for display purposes in the sigil-generated toc.ncx. There are times when the text contained between the 'h' tags may not be exactly what you want to see in the ncx ToC.

Rob Lister 03-07-2012 09:24 AM

Quote:

Originally Posted by DiapDealer (Post 1993094)
It uses the title attribute for display purposes in the sigil-generated toc.ncx. There are times when the text contained between the 'h' tags may not be exactly what you want to see in the ncx ToC.

That's what I figured but when I first 'figured' it, it didn't make as much sense as your explanation. I can now see that being a bonus. tx

GrannyGrump 03-13-2012 06:32 AM

Apologies for very belated thanks!
I knew you guys would have answers for me. I'm using the entity as suggested by Doitsu, working great. Timur, your solution works well for me if quotes are not mixed, but if I have double and single quotes in the text string, can't get it to work out.

Many thanks to all who responded!

Timur 03-13-2012 07:56 AM

Yes, you have to use entity representations, either &quot; or &apos;, if attribute value contains both string delimiter characters.

From Extensible Markup Language (XML) 1.0 (Fifth Edition):
Quote:

To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as " &apos; ", and the double-quote character (") as " &quot; ".


All times are GMT -4. The time now is 07:54 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.