ncx-generator can be used through Wine. It requires .NET Framework 4 to be installed.
ncx-generator have to be run through Wine's Console User Interface (
wineconsole
- installed with the wine package).This is the help file:
ncxgen [options] filename
-h, -?, --help Display this help.
--toc Generate the html Table of Contents.
--ncx Generate the NCX Global Navigation.
--opf Create the opf file package.
-a, --all Create both html ToC, ncx and opf files.
-q, --query=VALUE The XPath query to find the ToC items. Use
multiple times to add levels in the ToC.
-l, --level=VALUE Number of levels to collapse to generate the NCX
file - used with -ncx or -all.
-e Place the generated TOC at the end of the book
--toc-title=VALUE Name of the Table of Contents
--author=VALUE Author name.
--title=VALUE Book title.
-v, --verbose Turn on verbose output
-i Convert <PRE class='image'> tages to PNG images
--overwrite Overwrite files without any prompt
Example:
"ngen.exe -all -q "//h1" -q "//h2[@class='toc']" source.xhtml"
This expression will parse the xhtml file source.xhtml looking for the tag h1 an
d the tag h2 with an attribute class set to 'toc'. It will then create the html
Table of Contents, the NCX Global Navigation file and the OPF file using the it
ems found.
The difference between the Ubuntu Terminal and the WineConsole is, that you cannot use the TAB to fill in the filenames for you, and you have to refer to directories in your actual directory with a ./directory_name/ instead of using simply directory_name/ as in the Ubuntu Terminal.
To run the Windows Command Line Interface run wineconsole cmd
To run do this without opening the Windows Command Line Interface, just run the command through WineConsole, as if you were using the Windows CLI. This way it is possible to use the TAB to fill in filenames, which is a pleasure. The Windows CLI will be opened by WineConsole to run the command, and be closed when the running ends. If the user is prompted for keyboard input, the Windows CLI will stay open and wait for the user input.
~$ wineconsole ncxGen.0.2.6.exe -a -q "//h1" --author="Book Author Name" --title="Book Title" --toc-title="TOC Title" ./Test_Book/Book.html
This way NCX-generator can be integrated into bash scripts :)
Running a command like the above (with -a option) having a
Book.html
and a Cover.jpg
to begin with, will create the following files in the file directory:Book.ncx
Booktoc.html
Book.opf
Bookout.html
NOTE: if you name the cover image Cover.jpg, and put it in the same directory as the book HTML, it will be automatically recognized and included properly in the OPF file, when you run ncxGen. By specifying the --author and --title options too, you will not have to edit the OPF manually at all before building your book with KindleGen.
However, some UTF-8 characters are not properly recognized in ncxGen, so if you use i.e. Hungarian characters like ő or ű in the title, toc-title or author, you'd better check the OPF and correct it.
Nincsenek megjegyzések:
Megjegyzés küldése