Refining with a text editor

Share

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
</p>
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

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *