I’ve discovered pandoc

I have discovered pandoc. Oh dear.

It has garnered an immediate place in my backup routine and has filled a gap that my switch from Microsoft Word to LibreOffice Writer created in my editing and proofreading routine.

And I’ve discovered that I like reading the HTML version of my document better than the EPUB when I’m proofreading because paragraphs are spaced automatically instead of appearing in book form and that makes for really easy reading to pick out mistakes.

It’s also super easy to open an HTML file from Dropbox on my phone and tablets.

So, here’s how I made it work for me, in my routine. Maybe you’ll get a few ideas from this that’ll work for you.

First I installed pandoc. It is a command line tool so that’s a big deal for me. I don’t do command line work. I can, if I have to, but only if I’m looking at a cheat sheet. I have no advanced knowledge of command line stuff so what I present here is what I found in the pandoc documentation that worked for me.

One thing I do know how to do is create a .bat file for windows. I know only a few things about that, though, too.

That said, I know just enough to know it would be possible to do the thing I wanted to do once I realized how cool pandoc was.

So, let me start again: I installed pandoc. https://pandoc.org/

I followed the super easy installation method. I downloaded the windows installation file and ran it. :-)

The pandoc website is super easy to browse and I browsed right through the About, Installing, and Getting started pages. I skimmed the Demos and searched a bit of the Documenation at points too, but pandoc is really easy to use if you can just get the command line stuff right.

So here’s a cheat sheet. :D

It’s nothing special, but maybe seeing it will give you ideas.

I store my working files in a structure like this:

\users\myusername\files\publishing\works\series-name\01-book-title\

I do it that way so all my book folders are in the order I wrote them and not in some other random order.

I don’t even bother with the command line / terminal. I put my stuff in a .bat file that I created in notepad. Seriously.

I knew about .bat files and have used them for backing up files in the past. So I combined that with the stuff I discovered about pandoc and made a file that will generate a format for me and save it somewhere just by me clicking the file and “opening” it. .bat files don’t really open so much as they “run” so that’s what’s actually happening.

I click the file to open it and it runs. :D

Oh, and just to note, I’m using Windows 7. I don’t use Windows 10 so I have no idea if this stuff is just as easy there or not.

Once pandoc is installed, just right click in the folder where you store your book file and choose New Text Document from the context menu.

Here are supporting pictures to show me walking through what I did last night but in a dummy folder this time.

I made a new text file.

I named it “formats.bat”.

The file tries to default to “formats.bat.txt,” but I just deleted .txt so that the file is a .bat file. You’ll get a warning. Tell it you know what you’re doing and to rename the file extension.

Since I didn’t want to have to type up a crazy long file path, I had to make sure my file was actually in the directory where I put the .bat file.

If I’d been using one of my real book files like I did last night, this wouldn’t have been necessary because the file would have already been there. But that’s the problem wtih dummy folders. You’ve got to fill them with dummy files. :-)

Now I edit the file and put the pandoc command line stuff in it so that it’ll generate a couple of alternate formats and spit them out.

Here’s what’s in that file for easy copying and pasting:

pandoc book-title.odt -s -o book-title-draft.epub --metadata title="Book Title draft" --metadata author="Your Name"
pandoc book-title.odt -s -o book-title-draft.html --metadata title="Book Title draft" --metadata author="Your Name"

It won’t ask about overwriting files. So BE SURE you don’t mess up those file names and that you don’t mind having the files overwritten.

Just swap out “book-title.odt” for your file name.

Pandoc does handle .docx files too so you could start from that rather than an .odt file like I do. Also swap out the “book-title-draft.epub” (and .html) file for whatever name you’d like. Finally, the –metadata stuff is only relevant to certain file types so it isn’t needed for all conversions, say book-title.odt to book-title.txt. :-)

I use this to generate backup formats for my book, including a plain .txt file, and I actually have the EPUB and HTML files saved to my Dropbox folder instead of the directory it’s in so that I can open that file on my phone and do my editing read-through there or on a tablet.

These will be basic files, nothing fancy, but they are perfect for me to do my editing read-throughs that I do as I go, or as backup formats.

If you’re the type that prefers to start with something other than a blank document, you can take the EPUB or HTML into Sigil or Jutoh and tweak it there at the end if need be. I prefer to import my formatted word processing file for that into Jutoh, but it’s something I might look at just to see about when I get that far with my current book. :-)

It’s a one-click document generation and backup solution.

It is so easy. I love it. :D

Is it better to use LibreOffice’s built-in styles or custom styles for body text?

I’m trying to figure out if it’s better to use (and modify) the basic styles LibreOffice Writer includes by default or use my own custom styles.

LibreOffice’s default template comes with a style called Text Body that seems to be meant as a default style for all text body (not hard to guess that). The sub-styles are a little trickier to figure out until you look at what they do. First Line Indent is an indented paragraph by default, while Text Body is a block paragraph by default. Text Body Indent (not shown in the screenshot) is an entire paragraph of indented text.

To be honest, this all seems a little backwards to me, because I write fiction and a fiction manuscript is rarely formatted into block paragraphs. So Text Body would have to be an indented paragraph for me, while First Line Indent would make a lot more sense as a paragraph with the first line indent set to zero (0″).

Basically, I would need to create a LibreOffice Writer template that does the opposite with body text as what the default template does. That could get confusing if I were to create new documents with these same style names based on the default template instead of my template.

So, instead, I’m using custom styles for the text body paragraphs in my manuscript, not as a sub-style of Text Body but as a sub-style of the default style.

Indent has a sub-style called First to allow for a flush first line at the start of chapters and scenes instead of an indented one, and a few other useful styles I want based on Indent.

My reasoning is that if I change the body style (Indent), I want the style for First, End, and Scene Break to change too.

Also, the custom style names make sense to me, and probably to any other self-publishing writer out there who knows anything about formatting fiction books.

However, the moment you manually apply “Autocorrect” in LibreOffice Writer with the default settings in place, it strips out all your custom styles. I have no idea what purpose this serves since it will destroy the formatting of a finished document—unless it’s really only meant to be applied to a document you’re trying to reformat and you want it stripped down to basics first.

I’ve been tempted to make Indent a sub-style of Text Body, but Indent would still be a custom style, so I don’t think that’s the way to go. And in the end, I want the cleanest style set possible when I export stuff as HTML, which will create CSS styles, or import the ODT file to Jutoh (how I’ll create my EPUBs). I want short, meaningful style names, and I don’t want dependencies or inheritances I’m not aware of to mess things up in some obscure ebook reader I can’t test with my formatted ebooks.

Now that I’ve written it all out, it seems apparent that I want to stick with my custom styles the way they are. They make sense to me, and the reasons for keeping them independent of the built-in text body styles of Writer’s default style make sense too.

Is there anything I’m overlooking for this decision?

I’m really just getting to know LibreOffice Writer 6 and it’s entirely possible I don’t know something that could affect how this works out. If that’s the case, let me know.

Formatting is not always fun

Yesterday I took another trip around the world to get to my neighbor’s house.

Here’s what I mean.

The Kindle Previewer in night view was giving me trouble, but only for the Smashwords converted mobi file. The file I created with Jutoh and the one I created with Calibre were fine. Since those are the ones I upload and sell through other distributors, that’s good. But I couldn’t let the Smashwords issue go. I worked on trying to figure out what it was in my Word doc that was causing it. I even went so far as to generate a Smashwords odt file through Jutoh and tweaked it for Smashwords and the problem still didn’t go away. I was seriously on the verge of pulling out my hair when I decided to put that file on my actual Kindle (Fire) and see if it was a real problem or if the previewer had a bug.

Well, I don’t know that it’s a bug in the previewer because the previewer showed the font just fine in night view for my own mobi file. But when I side-loaded the Smashwords mobi directly onto my Kindle (I didn’t want the issue to get resolved by some conversion process if I used Send to Kindle to do it) and … no problems. None. Night view looked fine, although I can tell that there’s something going on with the file because in Sepia view the font is a bit darker than it should be compared to the mobi versions of the book I created in Jutoh and in Calibre (and compared to some other books on my Kindle too).

But I wasted hours trying to track down whatever might be causing the issue, because even after that, I didn’t give up. I tried setting after setting in Word, but nothing fixed it. I went so far as to delete my custom normal.dot file, copy all the text into a new document, and more.

Nothing fixed the issue. All I can figure is that it’s something to do with Smashwords’ own conversion process.

Regardless, I finally got over it my anxiety about this unexplained issue after I went back and pulled some of my older mobi files from Smashwords and checked them too. This problem’s been going on since 2012 at least, at least for my own Smashwords mobi files. I finally gave up trying to find a reason. I know I’ve checked the night view before, but since I’d always checked the Smashwords mobi by sending it to my Kindle, I’d never noticed the problem.

My decision to be more thorough this time and check the Smashwords mobi with the Kindle Previewer instead of just on my Kindle turned out not to be such a great idea. :o

Formatting is fun

I have no idea why I like it so much but I do love formatting my books! I also finally, finally figured out the solution to an issue I’ve been having with my table of contents not working on the Kindle and me having to do all kinds of things to get it to show up properly. I always intend to write down how I fix it when I format a book and then I forget and have to try to figure it out all over again.

To get the toc I’ve already created in Word to work once I import the file into my Jutoh project, all I had to do was right-click my Table of Contents document in the project organizer, choose Projects, and then select toc for Guide type. I also unchecked Show in Table of Contents.

I’m almost positive I’ve tried this before, but if I have, it didn’t work for some reason. I always ended up having to use the table of contents wizard and try the different options until I got one of them to generate a working TOC in the Kindle. The last few times I’ve had to delete my own table of contents list and let Jutoh manage it. I don’t like that because by default the generated TOC never quite matches my formatting and that bugs me.

But no more! The quick right-click thing worked without a hitch on two different projects last night. Yippee. ;) Just in case I actually knew this at one point and forgot, I wrote it down. The fact is, I’ve read the quick start guide and basically learned everything else in Jutoh by trail and error. :D Ah well. It works!