calibre follows all links in HTML files to create the ZIP from an HTML file. It does this recursively upto 5 (IIRC) levels of recursion.
The order that is used to combine the files into a single source is the "depth first" order of appearance of links. You can always customize this by creating an OPF file that specifies the desired order.
As for the TOC, you can use the --level*-toc options to create a TOC from multiple files. If you dont want to specify these options, the TOC can also be created from links in the files. In either case the algorithm for finding TOC elements is applied to each HTML file successively.
And for complete control you can create an NCX file that specifies the TOC and have calibre use that.
And on a general note, I should point out that calibre is designed for file *conversion*, not *creation*. The idea is that you use your favorite software to create the ebook and then calibre to convert it to various formats.
|