Thanks Dale, I'll take a look and do some fiddling (or maybe even some tinkering). In the mean time, for anyone else who wants to add line numbers to an ebook and does not wish to venture beyond the safety of a GUI, I came up with a pretty good way of adding the numbers in excel yesterday afternoon:
1) In Calibre, convert the book in need of numbering into an epub. Once its done, click on the "Click to open" link under "Path" in the info pane. Open the epub in Sigil (or, if you don't like directly editing the copy calibre uses, make a copy and open it in sigil). From the Book Browser pane on the left, click around the various html files until you find the one with the first chapter/book/whatever in it. Copy the text you want numbered (ie, not the chapter numbers/titles), and paste it into column B of an excel spreadsheet.
2) Now that the text is in excel, Go to cell A1 and enter the number 1. Go to cell A2 and enter the formula =IF(ISTEXT(B2),MAX($A$1:$A1)+1,""). Now, highlight cell A2 and drag down to the bottom of the text. Now all lines are numbered. If you're fine with each and every line having a number, leave it this way and proceed to step 3.
2a) If you prefer to have the lines numbered by 5s the way they are in print editions of poems, copy columns A and B and paste them into Notepad. Hit edit > select all and copy them out of notepad and into a new spreadsheet. (this is to remove the formula association from the line numbers column. If we attempt to remove the numbers that aren't multiples of 5 with the column still associated with a formula, it'll mess up the numbering). In cell C1 of the new spreadsheet, insert the formula =IF(OR(RIGHT(A1)="5", RIGHT(A1)="0"),"keep","remove") and drag down to the bottom. Under the Data tab of the ribbon, click on “Filter”. Click on the drop down menu under cell C1 and uncheck the box labeled “keep”. Highlight column A and hit the delete key on the keyboard. Go back to the filter drop down menu and recheck “keep”. Now the only lines numbered are those that are multiples of 5.
3) Delete the numberless text from the chapter's tab in Sigil. Copy columns A and B only of the excel document and paste them into Sigil under the appropriate chapter. Save and repeat for the next chapter, and so on. Once you're done numbering all the chapters, save and convert the epub to the desired format. (or, if you did not use calibre's epub in sigil, save, import to calibre, and convert to the desired format). There are probably some ways this can be streamlined, but I'll leave that alone for now.
Takes maybe 2 minutes per book, less than that if you don't mind having a number on every line.
|