Updated 3-Jan-2012 / Postscript added
One of the pitfalls of converting print publications to EBooks, is that designers often use forced line breaks (Shift+Return/Enter) in print-layouts to control where headings and even paragraph lines are broken. Doing so can cause problems when the same document is also converted to EPUB later on. Problems can occur when we leave the line breaks in the document, but also when we simply opt to remove them. Let’s have a look at what issues we encounter… and how we can fix things in InDesign without altering our layout 🙂 prior to EPUB export.
The EPUB Export dialog provides us with an option to Remove these Forced Line Breaks on the fly if preferred.
Forced line breaks in InDesign document (Colour code explained later on).
Let’s assume we are working with a publication that has been originally prepared for Print and must now be converted for EBook publishing (be it for EPUB or Kindle)… what happens to the forced line breaks that were inserted?
- if we opt to leave the forced line breaks in the InDesign document
- if we opt to remove them from the InDesign document
1. Retain Forced Line Breaks during EPUB export
What happens when we export the EPUB and retain the forced line breaks? Well in a nutshell, the resulting HTML will include
<br /> characters. And with altering font-size these characters might generate some very unpredictable (read: unwanted) line breaks in our text.
Break characters inserted in EPUB HTML.
Some unwanted line breaks appearing in the EBook.
2. Remove Forced Line Breaks during EPUB export
Looking at the example above, it seems clear that you’d want to remove the forced line breaks during export right? So let’s see what else can happen.
Possible result in EBook after line break removal (some ok, some not ok).
Yup, you’re not seeing things… (image above). Removing the forced line breaks can result in words being ‘fused’ together. Why does this happen in some cases and not others? Well, it’s all to do with the way the designer originally inserted the forced line breaks in InDesign:
- Recommended is to place the cursor in front of the character that needs to be moved to the next line, then press Shift+Return/Enter (GREEN). This retains the preceding space.
- Unfortunately this doesn’t always happen and in quite a few jobs I’ve worked on I encounter ‘missing’ spaces. In this case the space character between two words might have been highlighted when Shift+Return/Enter was pressed or the cursor was inserted at the end of a word when Shift+Return/Enter was pressed and then the leading space on the next line was removed manually. (RED)
No matter what happened, the removal of the space character as part of the forced line break insertion is causing a problem. So it’s important that we check our document for missing preceding spaces and fix things before we export our InDesign file to EPUB.
GREP Find/Change to the rescue
My preferred export way is to have the remove forced line break option enabled… it means less work in EPUB editing… IF we apply one essential step first before we export our InDesign document.
Basically we want to look for any forced line breaks in our document that are NOT preceded by a space character, and then we’d like to insert a space character in front of this break.
Tip: If you find yourself performing a ton of these Find/Changes prior as part of the EBook clean-up… consider purchasing Multi-Find Change plug-in for InDesign and you’ll be able to store all your EBook clean-up Find/Changes in a single set and apply them all in one hit 🙂 see: www.automatication.com
Here we go…
- Any character that is NOT a space: “\S”
- But we need to put it in a marking sub-expression, so we can put the character we found back in the text later on 😉 : “(\S)”
- Next we go look for the forced line break: “\n”
So our Find what string ends up looking like: “(\S)\n”
We now need to change things to:
- The non-space character we found earlier with the first sub-expression, so we don’t end up losing that character from the text 😉 : “$1” (Found > Found 1)
- Followed by a space-character followed again by the Forced Line Break: “ \n”
So our Change to string ends up looking like: “$1 \n”
Next click the Change All button in the Find/Change dialog and…
You can now safely Remove all Forced Line Breaks when exporting your InDesign document to EPUB. Best bit about this: There is no need to fiddle with <br /> tags in the HTML afterwards 🙂
Doug (comments below) mentions that there are indeed cases where you’d like to retain the Forced Line Breaks. Poetry for example. In that case you’d probably be more likely to remove the forced line breaks all together in InDesign for those paragraphs that are NOT poetry :), and opt not to remove them during the EPUB export. Once again I’m a big fan of trying to get the export as clean as possible from InDesign so there’s less to do with HTML/CSS later on. The one side-note here is that removing those forced line breaks would result in text reflow in the InDesign document. So if you’re looking at a single InDesign file for Print and EBook export, you’ll need to refrain yourself from using forced line breaks as a designer 🙂 As Keith mentions in his comment below. You could apply a ‘no break’ as an alternative.
Assuming you find yourself working with a document that has its text formatted with paragraph styles, you can selectively replace the forced line breaks in the text and replace them by a single space. We’ll cover both the scenario where we don’t have a preceding space and do have a preceding space in a single Find/Change action.
Find/Change replace All forced line breaks with a single space
Once again we look for
- any non-space character ‘ \S’ followed by a forced line break ‘\n’ OR ‘|’
- any space character ‘\s’ followed by a line break ‘\n’
If we turn the non-space character and space character into a Marking subexpression ‘()’, we can then set our Change to to just ‘$1’ 🙂
The only thing we still need to do is set the Find Format. If you don’t see this option in the Find/Change dialog, click the More Options button.
- Click the Specify Attributes to Find button
- In the Find Format Settings dialog choose the Paragraph Style for which you want to apply this Find/Change.
- And once again click Change All.
You’d need to repeat this Find/Change query for each relevant paragraph style.
Note: Tina Hender (@tinahender) tweets, that forced line breaks are also used for URL breaks. My guess would be that in this case you’re likely to see the forced line break at a ‘/’. I’d opt to perform a Find/Change that fixes these first of all. Again… Multi-Find Change for pre-EPUB clean-up will become a handy tool, as you can build this massive Find/Change Query Set in which a multitude of queries are run in one hit 😉