Refining with a text editor


At the end of the last blog, we had finished with our word processor document, and created a new text editor document by copying and pasting your novel.  This example uses the well-known editor TextEdit, popular with programmers.

In case you don’t know, an .html file requires each paragraph to be wrapped with the starting <p> and ending </p>  A variation is to use some of the special utility features such as <p class=”first_paragraph”> which you may notice I have done. This will be presented in the style sheet attachment blog later.

Again, this is our starting document after some preliminary changes in Word, then pasted into our text editor


<p class = “chapter_title”>Prologue
<p class = “location”></p>Western Iranian Desert
The rising sun sent a shaft of piercing yellow light across the arid world of the desert, impacting the pale sand, instantly raising its temperature, unofficially marking the start of another hot day in western Iran.


As it stands, the document needs changes to properly function in .html.  One glaring issue is that the </p> paragraph markers are not in the correct place.  Since our document is many thousands of words in length, we need some help to correct it, That is the job of the editor…to save you a lot of hand work.  The first step is to use the advanced search and replace feature. This requires the regular expression mode of your search and replace window as follows:

regular expression search                [\r\n]+</(.*?)>
replace        </$1>\n

The above instructions are strangely wonderful and will result in the following changes throughout your document.


<i> </i>

<p class = “chapter_number”>Chapter 1
<p class = “chapter_title”></p>Target
<p class = “location></p>Sunrise Beach County Park…Tacoma
1900 Hours</p>

The last remaining rays of the sun were being consumed by the trees on Vashon Island, across the narrow channel of fast moving water, and evening was extending its big hand across the little park, the light fading by the minute. The deep sound of a motorcycle moving slowly wafted in little bites, riding on humid air


That helped, but we now have paragraphs with  no endings and inappropriate paragraph endings within a sentence.  The next step is to find and replace unwanted paragraph endings as follows:

find      <p class = “location></p>
replace        <p class = “location>

And this will be necessary using any place that you see the </p> other than at the end of a paragraph.


And the next step is to add paragraph endings where needed with the following.  This time you need the regular expression search and replace (a check box in the search and replace window):


regular expression search      ^(.+)$
replace      <p>$1</p>


Those two actions resulted in the following:


<p class = “chapter_number”>Chapter 2</p>
<p class = “chapter_title”>Reunion</p>
<p class = “location>Interstate 5, South of Seattle</p>

<p>Special Agent April Chauncy couldn’t shake the feeling that she was being watched. She had used her FBI training, her best spycraft methods, to detect her pursuers but had no luck spotting them. It was probably a team, a very good one,


Looks a lot better, doesn’t it? But wait! We are adding another step to add flourish to your otherwise boring ebook.  We are going to change the first line of the first paragraph in each chapter. This will allow you to insert a fancy, large and distinctive letter to start the chapter and, as you will see, makes a great difference. Sorry. This time you have to do each chapter by hand by selecting the <p> which starts the paragraph and inserting the following:


<p class=”first_paragraph”><span class=”scrollfont cap”>T</span>


By the way, the letter T between the > < is the first letter you want revised.  You have to delete the first letter in your text and place it between the > < for it to work. In this case I was using a T.

This accomplishes two tasks. It allows you to have special formatting for the first line. For example, you may want to follow a long tradition using no indentation for the first line in a chapter. And it allows you to define in your style sheet the font you wish to display for the first letter.  You have to trust me for now and will understand completely when you see the style sheet and, later, the complete document.  Your book should be looking like the following:


<p class = “chapter_number”>Chapter 37</p>
<p class = “chapter_title”>From Out Of Nowhere</p>
<p class = “location”>Montgomery County Airpark, Gaithersburg, MD</p>

<p class=”first_paragraph”><span class=”scrollfont cap”>T</span>he plane was nearly finished and the tools and men gone. It sat on the smooth concrete gleaming like a new toy, an 18,000 pound one. All unnecessary hardware had been stripped, and the markings removed and


Don’t be confused by the display in your browser. The lines are set to display on your monitor but are actually full length in your text editor.

One last but important issue is the use of parentheses. The ones you used in your document are fine, but you should be aware that html statements use a special character parenthesis which is hard to detect visually.  You should do another search and replace for both right and left parenthesis, especially if you find unexplained errors.


Hope this gives you a little help or at least more insight into creating your own ebook.  Really, it isn’t as hard as it looks, and once you get the hang of it, it goes quickly and gives you all the control to present a very lovely ebook.


Alexander Francis



From word processor to HTML— Creating your own ebook file


In a previous blog, I briefly discussed taking your book from a word processor file to an html file and then to a format suitable for upload,  publication, and distribution as an e-book.

Now that I have ten books in print and also releases of them in ebook formats, including the Kindle version and the .epub versions, I have some comments about the process for my readers which may give more insight into doing the work yourself. You should know that I am not a professional programmer or web developer, and likely just like you, a struggling writer trying to get my books out to be read. In my case, I also created the covers and this web site you are now visiting.

I currently use Apple products after many years of using MS Windows.  Although I am a fan of Apple, I have issues with their primary word processor, Pages, which is easy to use but has created endless problems for me when I try to use my finished copy and produce a .pdf file for submission to Ingram Spark for printing and distribution.  Pages simply isn’t up to the task.  I have resorted to using a Mac version of MS Word for the final product, and yes, there are problems with that also,  but Word is capable of producing a fine finished product, given some caveats.

First all, NEVER use tabs when creating your book. Always use Styles for formatting and the reason will be shortly clear. Same with spaces.  Both extra spaces and all tabs will have to be eliminated before you can create proper html code.  Speaking of HTML, you should know that a typical  book uses very little sophisticated html programming code, and once you get the hang of it, you might find that you like it better than using  word processors with all their complex settings.

About an ellipsis in your work: That’s the little row of three dots … These are not simply three periods, though that’s how you create the ellipsis when typing.  An ellipsis is a unique character in the world of computer character sets, not three periods.  Your word processor (hopefully) will take your three periods and convert them to a single ellipsis character. The reason I’m discussing this is to outline a problem with Word and other processors such as Pages.  Copying your text from Pages and inserting it into Word does not convert your three periods to a proper ellipsis.  Only typing the three  periods in Word produces the ellipsis. Searching in Word won’t find what you thought was a proper ellipsis.  Be warned.  The reason I bring this up is because of how your sentences are handled during formatting and your particular wishes of how to display your ellipsis.  Correct form of using the ellipsis is controversial and you may choose to use a leading or following space, both or even none. All more difficult to  do if your word processor isn’t seeing an ellipsis  as a single character.

Assuming you took my advice and used Word to produce your final version of your book, you now want to convert your document to an .html file. I will give you some examples of how I do it. There are more steps after conversion but more on that later. A word of advice regarding Word. There is a feature that ‘automatically’ coverts your document to an .html file. Save yourself the agony because it won’t work and will be large and overly complex.  There are also sites on the web which offer to convert your finished pdf file to a .html or even a .epub or Kindle format.  Perhaps. But they won’t do as good a job as you can and their output will never be as beautiful as your hand finished work where you have control over the smallest detail.


Below is a small sample from my book Elapid.  I can’t display the fonts and style I actually used in the book on this web page, so you can either go look at the original or try to have some imagination.  My book was created using styles for the chapter numbers, the chapter titles and the location, as well as formatting for the first and following paragraphs. While still in Word, you should prepare your work as follows:

Eliminate your fancy dropped cap or graphic for the first letter in the chapter.

Remove any graphics, and as mentioned, all tabs and extra spaces.

Change your style settings to remove any use of italics, but don’t remove the italics used in the body of the text of your book.

Don’t forget to save your file using another name unless you want to lose your valuable original!

Original Example


Western Iranian Desert

The rising sun sent a shaft of piercing yellow light across the arid world of the desert, impacting the pale sand, instantly raising its temperature, unofficially marking the start of another hot day in western Iran. The snake understood, by experience and by genetics, that a sheltered place, hidden in shadow, would be necessary to survive another day, and

Using the Advanced Search tool (Find and Replace) in Word, select the Format button and search for Font…Italics.

Then use the following expression in the Replace With area:


This will outline your italicized text for proper display using HTML.


Now we are going to do the same with all our style settings so that our style sheets in HTML can do the same thing your word processor was doing.

My Word style for my chapter titles was named  chapter_title and I search for all occurrences by selecting that style in the Find and Replace tool.  Then replace with the following:

<p class = “chapter_title”>^&</p>


Do the same for your chapter number style and your location style (if any).  Your document will start to look like this:


Second Example:

<p class = “chapter_number”>Chapter 1
</p><p class = “chapter_title”>
<p class = “location”></p>Sunrise Beach County Park…Tacoma
1900 Hours
The last remaining rays of the sun were being consumed by the trees on Vashon Island, across the narrow channel of fast moving water, and evening was extending its big hand across the little park, the light fading by the minute. The deep sound of a motorcycle moving slowly wafted in little bites,

Not very pretty, is it?  And you may have noticed that the  formatting extends across lines.  We’ll fix that using the text editor, not to worry.

You are done with the word processor.  Select the entire document and copy it into memory.  Using a text editor (I use TextMate), paste your book into a new document.  Now the fun starts.


Look for another blog on what to do next!


Alexander Francis