Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 01-18-2024, 02:05 AM   #1
jugaor
Enthusiast
jugaor began at the beginning.
 
jugaor's Avatar
 
Posts: 30
Karma: 10
Join Date: Jun 2011
Location: Lima, Peru
Device: Kindle 10Gen / Kobo Aura HD / Nook STR
Question xhtml, nav, css headers

Hello everyone.
First, thanks to the developers for their work on this great tool.

I have had this doubt for a long time (epub3):
Why is the header of the nav file different from the rest of xhtml files?

Section0001.xhtml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
  <title></title>
</head>
nav.xhtml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="es" xml:lang="es">
<head>
  <title>ePub NAV</title>
  <meta charset="utf-8"/>
  <link href="../Styles/sgc-nav.css" rel="stylesheet" type="text/css"/>
</head>
That is to say:
1. Why is the 'charset' line added only in nav? Is the 'encoding' of the first line not enough?
If the answer above is "no":
-Why isn't it added to the rest of the xhtml files?
-Shouldn't it be before the < title >, in case it has 'special' characters? (in previous versions of Sigil it was like this.)

2. Why are language tags added only in nav? (in my books, by default in Spanish.)
Same case above: shouldn't they be automatically added to all xhtml?

3. (epub2): I know that language tags do need to be added (at least 'xml:lang="es"'), but should 'charset' be added as well? (toc + xhtmls)

4. Finally, if I may compare, Calibre Editor automatically adds this initial line to each CSS:
Code:
@charset "utf-8";
but Sigil doesn't. Is it also necessary?
(Actually, in real life, I've only seen it in Standard Ebooks... )


Thank you so much! (and sorry for the automatic translation.)
jugaor is offline   Reply With Quote
Old 01-18-2024, 08:56 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,654
Karma: 5433388
Join Date: Nov 2009
Device: many
1. The charset is set in the nav as a backup encoding declaration since nav's are machine parsed to create the toc much like the old ncx was (ie act in a stand alone manner) and that parsing software is not always robust depending on the e-reader. Placement before or after the title is not relevant. Typically it is grepped for in the first 1024 characters by software that tries to guess character encoding.

2. language can be determined for all xhtml pages from the opf first dc:language metadata tag and if the xhtml only uses a single language this is all that should be needed. Accessibility has now made adding it more important as screen reading software typically does not grok the opf. So adding xml:lang and lang attributes to tags when specifying a language being used is always a good idea for accessibility reasons. Again this is added for the nav as it is independently machine parsed to extract landmarks and toc info by specific e-reader device software and should stand up on its own as a backup..

If you want to automate adding lang attributes as part of Sigil for all xhtml pages, you can easily do that in Sigil using plugins (Access-Aide), or just specify your own default xhtml file template (see our latest user guide for details) or just use global find and replace once at the end.

3. not unless that xhtml is meant to stand alone outside of the opf or epub. The xml header specifies the encoding. But support for anything other than utf-8, utf-16 ((le or be) and utf-32 has been long deprecated and the final 2 should use byteorder marks that determine / identify them. All other 8 bit encodes should be transcoded to utf-8 properly before adding them to your xhtml file.

Here is what the w3c says about xml/xhtml and the use of charset:
Quote:
The charset attribute specifies the character encoding used by the document. This is a character encoding declaration. If the attribute is present in an XML document, its value must be an ASCII case-insensitive match for the string "UTF-8" (and the document is therefore forced to use UTF-8 as its encoding).

The charset attribute on the meta element has no effect in XML documents, and is only allowed in order to facilitate migration to and from XHTML.
4. By default now all css is considered to be utf-8 encoded. Here is what the latest mdn spec states about use of charset in css:
Quote:
The @charset CSS rule specifies the character encoding used in the style sheet. Although the first character in @charset is the @ symbol, it is not an at-rule. The CSS syntax module deprecates this rule, defining it as an unrecognized legacy rule to be dropped when a stylesheet is grammar-checked, but it is fully supported in all browsers.
So adding that can not hurt but it is not needed anymore and it is one of the first things removed by most css minimizer or linting software software when speed of access is determined to be important for web pages.

Last edited by KevinH; 01-18-2024 at 11:11 AM.
KevinH is offline   Reply With Quote
Advert
Old 02-12-2024, 01:09 PM   #3
jugaor
Enthusiast
jugaor began at the beginning.
 
jugaor's Avatar
 
Posts: 30
Karma: 10
Join Date: Jun 2011
Location: Lima, Peru
Device: Kindle 10Gen / Kobo Aura HD / Nook STR
KevinH, sorry for the late reply.
Thank you very much for your kind and clear answers.

Best regards!
jugaor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
using nav.xhtml for TOC hobnail Sigil 40 11-12-2021 02:00 PM
Link to nav.xhtml in TOC cges30901 Sigil 11 01-22-2020 12:01 PM
Doubt about nav.xhtml and editor Terisa de morgan Editor 5 08-12-2018 11:51 AM
TOC nav.xhtml issue ebookscovers Conversion 1 05-06-2017 11:12 AM


All times are GMT -4. The time now is 02:53 PM.


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