On Sun, 13 Jul 2014 18:00:39 -0500
Les Denham <lden...@hal-pc.org> wrote:

> On Mon, 14 Jul 2014 01:08:47 +0530
>  Frederick FN Noronha फ्रेड्रिक नोरोन्या *فريدريك نورونيا
> <fredericknoro...@gmail.com> wrote:
> 
> > * What is the easiest way to convert a Lyx file (with images) to
> > epub?
> > * How can one ensure this will be consistent with epub standards?
> > * Any site to test the resultant epub?
> > * Can Lyx developers help to develop some tools that make it easy to
> > create epub and other formats of ebooks?
> 
> Frederick,
> 
> I've done this for several books. From my experience the answer to
> your questions are:
> 
> * Conversion
> 1. Export your file to LyXHTML
> 2. Using your favorite text editor (I use vi), delete the first line
> of the file (something like <?xml version="1.0" encoding="UTF-8"?>)
> and save as type HTML.
> 3. The file can now be imported into Sigil
>   (http://web.sigil.googlecode.com/git/files/OEBPS/Text/introduction.html),
>   which saves files in epub format.
> 
> * Epub standards
> Sigil includes the FlightCrew validator, and also a link to validate
> stylesheets with W3C.
> 
> * Testing the epub
> I don't know of any site for testing, other than
>   http://validator.idpf.org/, which as far as I know does exactly the
>   same as the Sigil validator. The real problem is that no e-reader
>   supports the standards completely and exactly, so you need to test
>   your epub on several readers. I use Nook, Calibre and FBreader.
> 
> * LyX development
> I'll leave this to developers.
> 
> Without images, the conversion is straightforward, with the main
> problem being how to handle footnotes: as epub is reflowable, the
> concept of footnote does not exist, so you will have to decide how to
> handle them. Sigil gives you the tools to implement any solution you
> decide on, but it may involve a lot of detailed editing.
> 
> Images complicate the conversion. Do you want small images in a fixed
> location in the text? That is fairly easy. So is putting all the
> images at the end of a chapter (or at the end of the book). But if
> you want clickable links to images, and a clickable link to return
> you to the page you were on, it can become very complicated, and
> involve a lot of hand editing. But again, Sigil has all the tools you
> need for this.
> 
> I hope this helps,
> 
> Les

Thanks Les!

The preceding helps a lot if I want to convert my existing LyX written
books to ePub. For new construction my plan is to use either (Docbook)
XMLMind, which outputs both PDF and ePub, or to write my books in Sigil
and make some scripts to convert Xhtml to LaTeX.

A few additions to your instructions:

After deleting <?xml version="1.0" encoding="UTF-8"?>, you can import
the HTML file like this:

sigil myexport.html

Then, within Sigil, File/Save. Upon using ebook-viewer to view the new
ebook, you might get a message something like this:

File Section0001.xhtml not in OPF file.

If that happens, look in toc.ncx and remove the entire element set for
Section0001.xhtml, and this error should vanish.

You should also make sure to place your downloaded

Within Sigil, you can Tools->contents to produce both the HTML contents
that go in the front of the book, and the device contents you get when
you press the contents button on the device.

Next, make CSS local by downloading the web-linked CSS file linked in
the HTML (text) portion, importing it into the Styles directory of your
ePub, and changing the link accordingly. This can all be done using the
Sigil GUI, you don't need to code it, IIRC. You'll probably have to
manually delete the old, web based CSS file reference manually, though.

Now that you have local CSS files, you can change the appearance of
whatever you want, and can add new CSS files for niche purposes.

Next, search out all ERT from the old LyX file. ERT is copied right
into the ePub as text, so you need to back it out and substitute CSS
styles for all ERT. Remember all those years I championed ERT for the
frontmatter? Well, now that there's ePub, my old suggestion is the kiss
of death. ALL appearance should be implemented through styles, even if
that means making a style for a single paragraph or phrase in the book.
If you do new-construction ePub authoring from LyX (and I don't
recommend doing so), you need to author styles-only, with absolutely no
ERT anywhere in the document. Also, when doing new construction, don't
use figure frames for illustrations: Just dump the .jpg or whatever
right into the Lyx, and make them small enough to view on a small
screen.

Tables, unless they're very narrow, don't do well in an ePub, as would
be expected. Sometimes expressing something as a table is a great way
of expressing it, but not if one of your outputs will be flowing-text
files destined for small devices. Consider finding a way of expressing
the info, other than tables. By the way, this would be true if you
authored straight into Sigil: You just can't put wide things in a file
destined for a device.

After completing all patch-up, you need to comply with the modern eBook
custom of starting each chapter at the top of its screen, and the only
dead-bang sure way to do that is to have each chapter be its own file
within the text directory of Sigil. So search each chapter (presumably
an <h1>), and immediately before it press Ctrl+Shift+Enter to create a
chapter mark. Do this just before any Part sections too. When you've
marked all chapters, perform menu command Edit->Split_at_markers to
split into files per chapter. Now your book will start every chapter at
the top of the screen.

I did the preceding on my eBook "Twenty Eight Tales of
Troubleshooting", and it represents between 30 and 90 minutes of hand
made patch-up, which means you don't do that every time you change a
typo or the like. This implies keeping a LyX copy of the book's source,
and a LyX copy for PDF/Print. And of course, the two source paradigm is
hard to keep in sync.

The LyX produced ePub looks decent: It looks like a flowing text
version of a LyX produced PDF, which is great if that's how you want
your ePub to look, otherwise it's not good. I don't use figure frames
so my illustrations came out just fine, if a little small.

The ePub's HTML code is half-semantic, pigeon-HTML that produces a
readable book, but I have a hunch it would never pass muster for a
Kindle book. Paragraphs are <div></div> instead of the more semantic
<p></p>. 

===================================================================
NOTE: Sigil too substitutes <div> for <p> if you're not careful, but in
Sigil, you can tell it's doing that, and convert from <div> to <p>
simply by clicking <h5> and then clicking <p>. Then, until the next
<h?>, all further paragraphs created by pressing the enter key are
automatically <p>. It's a bug and workaround you can live with.
===================================================================


In a LyX authored ePub, paragraphs come in two classes, indented and
unindented, which is a complication and a violation of the spirit of
styles-based authoring. Nobody reading an ePub expects for the first
paragraph of a section not to be indented, so this is not necessary:
They all can be indented and the book will be accepted just fine. 

<h2> tags have classes indicating whether they're in the table of
contents, which is unnecessary because the table of contents can be
built quickly through Sigil, and the LyX TOC, at least for me, failed
to reproduce on import anyway. The <h1> chapter based tags needlessly
include class="Chapter". All cross references, including tables of
contents, are produced with long ago deprecated <a id="whatever">
instead of the current method of putting the id in the <h1>. This
deprecated method can produce the dreaded "see the same page twice"
error in Kindle books, and is specifically forbidden in the Kindle
authoring specifications.

So, I'll continue using LyX for books requiring heavy math (which
should never be read on a small device anyway), but otherwise I'll be
using either pure Sigil authoring or a Docbook solution for books I
write from now on. Sigil has a user interface quite similar to LyX
itself: No visible tags in the "book" view, and somewhat WYSIWYG so
you know just where you are in the file. I haven't pounded out 2500
words a day in Sigil yet, but it looks doable. If anyone can help me
write Python scripts to convert Sigil-authored ePub to LaTeX (basically
using Python's XML parser, and passing styles, not appearances), please
let me know.

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

  • ... Frederick FN Noronha फ्रेड्रिक नोरोन्या *فريدريك نورونيا
    • ... Les Denham
      • ... Frederick FN Noronha फ्रेड्रिक नोरोन्या *فريدريك نورونيا
        • ... Alan L Tyree
        • ... Steve Litt
      • ... Frederick FN Noronha फ्रेड्रिक नोरोन्या *فريدريك نورونيا
      • ... Steve Litt
    • ... Steve Litt

Reply via email to