View Single Post
Old 12-13-2021, 12:42 AM   #6
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by roland1 View Post
Crap: I just wrote a decent, lengthy post with a lot of info, clicked "go advanced" and lost it all after I had to log in again. DOH!
Yep. Always best to type everything in an external text editor. THEN you can copy/paste it into the box.

Won't lose anything that way.

Quote:
Originally Posted by roland1 View Post
P.S. I haven't really used "checkpoints" but rather I just keep making backup copies as my work progresses. Takes up more real estate, but it's a workflow I'm used to.
Yep, that's a similar method to what I use too.

Tip: Save files by proper date:
  • Book.Title[YYYY.MM.DD]

that will make sure your files sort in order alphabetically+chronologically.

Checkpoints also are good if you're doing something major—like generating an Index. Makes it easy to jump back to the previous version just in case you messed up.

Quote:
Originally Posted by roland1 View Post
I used Affinity Publisher for the print book layout. Excellent and cheap, BUT it does not export to anything but PDF for now.
Never had the pleasure of using it.
  • And there's no HTML export?
  • What about RTF or something with a little bit of formatting it in?
  • Or is it really PDF export only?

What if you copy/paste the text out of Affinity + into another program (like LibreOffice):

Does it carry over the rich text formatting? (Italics, bold, hopefully indentation, etc.)

If it does, then that'll be a little easier. Then you won't have to manually add the italics back in.

Use that intermediate program to export your text to HTML.

Quote:
Originally Posted by roland1 View Post
re; Index: I assumed I would have to add the "See also" after finishing the index because it made sense that it would just get erased with each overwrite. I can live with that.

I'm taking the word for word link coding approach. Very tedious, but if I get through this process once, I won't have to do it again.
Don't manually add all that "See also" text.

Just work directly from the Print version you have + use regex (regular expressions) to linkify the page numbers.

I explain exact methods in those linked threads, but I'll reword it slightly differently here:

* * * * * *

How to Make Your Index Links

0. Make sure you insert all your page number code at every page break!

Code:
<p>This is an example<a id="page123"></a> of a split paragraph.</p>
1. Merge all your main chapter files into one huge HTML file. (You'll thank me later.)

I rename this super merged book file to:
  • merged.xhtml

(Make sure you keep the index.xhtml file separate.)

2. Open your Index file.

3. Ctrl+F to open Sigil's Search/Replace.

In the dropdowns, make sure these are selected:
  • Mode: Regex
  • Current File

+ uncheck the box for "Wrap".

4. Use regex to convert those dumb page numbers into links:

Search: (\d+)
Replace: <a href="../Text/merged.xhtml#page\1">\1</a>

- - - - - -

Side Note: If you don't know regular expressions... this is what all the parts are doing:

Search:
  • \d = any number
  • + = one or more of the previous thing
    • So in this case, "one or more of any number"
  • () around stuff = "Capture whatever's in here, and shove it in a 'group'."

Replace:
  • <a> = all the link code
  • \1 = The stuff we captured in the Search.

In Plain English, this regular expression is saying:

"Hey, look for any number, grab it, then point to that page number in the merged file."

- - - - - -

5. Click somewhere right before the very first entry, then press "Replace All".

This will go from my "Plain Index" -> "Linked Index" above:

Before:

Code:
cats, 5
dogs, 123
parrots, 200
After:

Code:
cats, <a href="../Text/merged.xhtml#page5">5</a>
dogs, <a href="../Text/merged.xhtml#page123">123</a>
parrots, <a href="../Text/merged.xhtml#page200">200</a>
6. Doublecheck and make sure you did all your page number code throughout your main text.

Now, you can split your chapter files again:

6.1. You can manually click before each of your chapters, then Insert > Split Marker (Ctrl+Shift+Return).

That button inserts this code:

Code:
<hr class="sigil_split_marker" />
6.2. (Alternate) Or you can insert all those markers in one shot by Search/Replace.

If you have proper Headings (or some common text that stands out):

Search: <h2>Chapter
Replace: <hr class="sigil_split_marker" /><h2>Chapter

then "Replace All".

Before:

Code:
<h2>Chapter 1<h2>
[...]
<h2>Chapter 2</h2>
Replace:

Code:
<hr class="sigil_split_marker" /><h2>Chapter 1<h2>
[...]
<hr class="sigil_split_marker" /><h2>Chapter 2</h2>
7. Edit > Split at Markers (F6).

Now all your chapter files will be resplit into separate HTML files again.

8. Rename all your HTML files to human-readable names:

- Chapter01.xhtml
- Chapter02.xhtml
- [...]
- Chapter99.xhtml

* * * * * *

Now, when you go back to your Index, you should see all your page number code updated:

Code:
cats, <a href="../Text/Chapter01.xhtml#page5">5</a>
dogs, <a href="../Text/Chapter15.xhtml#page123">123</a>
parrots, <a href="../Text/Chapter28.xhtml#page200">200</a>
And to doublecheck your links work... Press Tools > Reports > Links.

If you "Target exists?" column has any "no", then you know you have a broken link.

Side Note: For more explanation on what the columns mean, see my post from a few months ago:

Last edited by Tex2002ans; 12-13-2021 at 12:47 AM.
Tex2002ans is offline   Reply With Quote