Removing Forced Line Breaks & Nonbreaking Hyphenation in InDesign to ePUB

InDesign Find/Change Dialog Box for Removing Forced Returns from Text Tab
  • Sumo

When converting the InDesign file of a book created for print, you need to be aware of the choices the print designer made, including how and where they have used forced line breaks and forced hyphenation. If these tools were used by the print designer, you will need to clean the files up, either prior to ePUB export or after export.

One of the great things about the general ePUB format is that text is reflowable; there is no fixed page in the ePUB. The page will reflow based on the eReader device or software that a reader is using and the reader’s personal preferences in font and font size.

This is very different from a print book in which a designer may use forced line breaks or soft returns and forced hyphenation to make lines and pages break at certain points, often to avoid loose or tight lines, widows, orphans, or bad breaks. Designers may also add forced breaks to heads so that if they break across multiple lines, the lines are relatively equal in length or the break occurs at a point that improves readability and understanding of the head’s meaning.

Before we start, a reminder: If you are going to make substantial changes to the print InDesign file before exporting to ePUB, it would be best if you created a copy of the print file and use the copy when making changes and exporting to ePUB. You have been warned.

The best way to add a forced line break (shift + Enter/Return) is to do so after the space separating two words. If all forced line breaks are done this way, it should be relatively painless to remove them in InDesign using Find/Change with the Text tab:

InDesign Find/Change Dialog Box for Removing Forced Returns from Text Tab

InDesign Find/Change Dialog Box for Removing Forced Returns from Text Tab

You can also use the GREP tab to do the same thing:

Removing Forced Line Breaks Using Find and Replace GREP tab

Removing Forced Line Breaks Using Find and Replace GREP tab

This will delete the forced line break. The text from the line following the deleted forced line break should roll back and there will be a space between the last word before the forced line break and the first word after the forced line break.

Unfortunately, it is not uncommon to find that the forced line break was placed immediately following a word in the print ID file. When this happens, the space following the forced break is often deleted since the text of the following line will no longer be flush left in the print ID file. If you do a simple Find and Replace to delete the forced break, you will close the two words together.

In Cari Jansen’s post I mention below, she provides GREP you can use to fix this. Go to the GREP tab. Simply Find what: (\S)\n, where (\S) is any character that is not a space, and Change to: $1[single space], where $1 simply means include the character found in (\S). This will add a space after the word immediately preceding the forced line break and delete the forced line break.

Find and Replace Forced Line Break in InDesign without Space Preceding It Using GREP

Print designers may do something similar with word breaks by adding forced hyphenation. This is usually done to ensure that words that normally appear with hyphens in them break only after the hyphen or to prevent bad breaks in words (before single vowel syllables, before liquid el syllables, etc.).

My suggestion is that you remove both nonbreaking/forced hyphenation (^~/~~) and discretionary hyphenation (^-/~-) from the InDesign file prior to ePUB export. Unfortunately, you will probably want to perform the Find/Change on each occurrence individually since a hyphen may or may not be need at the place where the nonbreaking or discretionary hyphen has been added. If there should be a hyphen in the word at the point where the nonbreaking hyphen appears, replace with a hyphen; it there shouldn’t be a hyphen, delete the character and close the word.

You may also find that non-breaking spaces (^S/~S or ^s/~s [fixed width]) have been used to control where lines break. You may want to replace these with normal spaces to remove any chance of incorrect or unintentional rendering in an eReader. In CS5.5, both will export as  . In CS3 and 4, the regular nonbreaking space will export as as  ; the fixed width nonbreaking space will not.

If you don’t want to make changes to the InDesign file before export to ePUB, you can have InDesign remove forced line breaks on ePUB export by checking the Remove Forced Line Breaks box on the  EPUB Export Options/Contents dialog box.

EPUB Export Options dialog box, Contents tab, Remove Forced Line Breaks checked

EPUB Export Options dialog box, Contents tab, Remove Forced Line Breaks checked

Cari Jansen has a wonderful post at carijansen.com on this titled “Building EBooks with InDesign—Forced Line Breaks.” In this post, Jansen suggests using GREP to insert a space after the last letter of the word proceeding a forced line break if it is not there to ensure that you do not close two words that should remain open.

If you neglect to remove forced line breaks in the InDesign files prior to export or during export, you will find that a break tag, <br />, will be inserted wherever a forced line break occurs in InDesign. Don’t lose hope; you can always edit them out of your ePUB using your text editor and Find/Replace or RegEx.

Are you dealing with these issues in other ways? What else have you found in InDesign files that were created for print that you need to delete or replace for export to ePUB?

11 Responses to “Removing Forced Line Breaks & Nonbreaking Hyphenation in InDesign to ePUB”

  1. To avoid doing multiple searches, perhaps you could directly search for the GREP pattern “([\S| ])\n” and replace it with “$1 “?

    In case it finds a space+forced line break, it will add a second space, which is not a problem in html.

  2. Streve says:

    Indeed. You could skip GREP altogether and just replace every forced line break with a space.

  3. Mile says:

    I´m struggling with this hyphenation issue, because i’m working with spanish texts so my epub doesn’t recognize the spanish dictionary, is there any way to solve this problem?

  4. Matthew says:

    Hyphenation support is largely a reading device/app issue. With EPUB3.0 coming, multiple language support is included in the spec. Unfortunately, it will still fall to the reader to hyphenate currently. You need to define your language as Spanish in the OPF file (en), but if the hyphenation issue you are having is on the reader, I’m not sure you can do anything to the file to fix it; it needs support from the reader software.

  5. Staci says:

    Hi everyone, it’s my first go to see at this web
    page, and paragraph is actually fruitful in favor of me, keep up posting these articles.

  6. Rencana Tuhan selalu lebih indah dari keinginan kita

  7. Phil says:

    excrllent publish, very informative. I ponder why
    the opposite specialists of this sector do not notice this.

    You should continue your writing. I am confident, you have a great
    readers’ base already!

  8. Samual says:

    Many people thouyght ѕɦe.

  9. MSPHack.tips says:

    Whethеr үou are օn 3G օr LTE, yoᥙ can see wҺatever уօur cam is
    recording, beѕt fοr monitoring ʏoսr house ԝhile you аre away.