Join Anne-Marie Concepción for an in-depth discussion in this video Using free scripts to automate text formatting, part of InDesign CS6: EPUB Kindle and iPad.
I'm a big fan of using free InDesign scripts or even ones that I have paid for to help automate a lot of tedious tasks. And definitely one of the most tedious tasks in InDesign is prepping an InDesign file for EPUB Export. Big part of that is finding a locally formatted text and creating a character style and applying that so that we can choose the option when we export to EPUB not to honor local formats. And the reason for that I explained in the previous video, because it makes for much cleaner markup if you only use character styles and paragraph styles and not local formats.
Now this sample document that I have open has a ton of locally formatted text. So, for example, if I click right here in this italic text there's no character style called italic. In Paragraph Styles you'll see the plus symbol appear, and if I hover over it you'll see that it says override it's italic. And same is true for this bold italic, the same is true for this small caps hover over this, small caps. Now wouldn't it be nice if there was a way that we could quickly get InDesign to put like a glowing amber light behind every instance of formatted text, so you don't have to keep clicking in text and checking over here.
Well, not yet, but there is something that comes close, and that is a free script by the good people at in-tool.com, and it's called show local formatting. Now this is an interesting kind of script, you actually need to install it and then restart InDesign, so we're going to just going to ahead and do that. So I'm going to close this document, we'll come back to it, go to your Scripts panel it should be part of your EPUB workspace. And if it's not there go to the Window menu down to Utilities and choose Scripts.
We need to open up the Scripts panel, because we are going to use it to navigate to where we're going to put the script from in-tools. It finds where it says application in your Scripts panel and then right-click and choose Reveal in Finder or Reveal in Explorer. Now the Application scripts folder is actually in the program folder, and this is the Script panel. We want to put this script that I'm including into startup scripts, which I have already done, it's called ShowTextOverwrrides.jsx, so just copy and paste or if you download it from in-tool website, put it here and then restart InDesign, so I'm going to quit and then restart.
We needed to restart because this script adds a menu item, and if you look under the Type menu, we will see, ah-ha! Show Text Overrides, right. So now you can open up a document and choose this command, and you get this nonprinting highlighting over anything that is a text override. So it's kind of like show hidden characters and hide hidden characters, it's really great to be able to quickly track down where is the overset text. Now you maybe wondering hey what about this text down here, isn't this overridden? But actually it's not, because if we go to the Paragraph Style panel there's no plus symbol, this is actually a nested style inside the body list paragraph style.
If you look in the Character Styles panel, you'll see that it uses bold leading as part of the paragraph style. So there is absolutely no problem with using nested styles, GREP styles, nested line styles because those all require the use of a character style and all that is supported when you export to EPUB those will all be marked up properly. Now let's hide our text overrides, and we're going to use another script to quickly create the character styles and apply them where necessary. This script, I also include in the exercise files in this folder, and you want to copy and paste them into the good old EPUB folder.
There are actually three scripts that I have added here. The first one is called preptext.jsx, and that PrepText is by this wonderful guy name Jongware--that's his screen name of course-- he hangs out a lot on the indesignsecrets.com forums, that's the log that I co-host. And he wrote this a couple years ago in response to somebody who said, I have all this locally formatted text, and I need it to automatically be character styles. But the problem with running PrepText by itself is that, well actually let's just do that. I'm going to go ahead and double-click on PrepText, and it's prepping the text, and now it's done.
So did it do anything new? Well, let's see, let's go to the Type menu and choose Show Text Overrides. Nothing there buddy, let's Hide Text Overrides and see what it'd do, I'm going to click here, go to the Character Styles and look it added the correct character styles, and it applied it as necessary. So there it is it's actually bold italic this is just I think a screen redraw problem there you go. But what is the problem with running PrepText by itself? You'll see let's export this to EPUB, I'll just press Command+E or Ctrl+E, put it right on the desktop and just make sure that you're using EPUB2 view EPUB after exporting and in advanced you don't want to include local overrides, of course it's a whole point of this nor Embeddable Fonts for now just Include Style Definitions.
Looks good, all the formatting is maintained, but let's open this up in TextWrangler we take a peek at some of the markup, so I'm just dragging and dropping this over to the TextWrangler which opens up archives let's just peek inside and here is our file. So what happened here is that we have a paragraph style called subhead and subhead automatically makes the paragraph bold. But Jongware's PrepText script is actually meant for when you first bring in a Word document, for example, and it's all full of local overrides, but you haven't applied paragraph styles yet.
So if this text is already have paragraph styles applied to it and what it's done is it's done a double hit, so this paragraph style subhead for Flemish Painting, it said oh that's bold, so let me apply the character style called bold to it as well, and that happens throughout here. If you looking you're InDesign document this was perfectly fine as the paragraph style, it does not need a character style bold, you may say oh let's hit plus symbol that's only because they made the type larger I am going to click the Clear overrides button to get rid of overrides here. Here we go just Option-click or Alt-click here there.
So, there is subhead, we don't need bold. If I change it to none it would look exactly the same. So that makes it little difficult to work with, because these are superfluous tags, so let's close this. I presented this problem to a friend of mine Peter Kahler who is a wonderful InDesign scripter, and he didn't an add on for all of us that works with Jongware's PrepText and what it does is that it avoids the double hits. I want to revert this file, and now we are as we started with the local overrides are still here.
In the Scripts panel there are two versions of what Peter wrote for us PerfectPrepText_Ask and PerfectPrepText_Do. If we double-click the do one it automatically does what Jonware's script does, it actually needs PrepText at the same level, so if you have it installed it won't run, and it'll give you an alert. And it applied and created the character styles as before, but it did not apply the character style to text that doesn't need it, so we don't get that double hit.
So PrepText do, we'll just go ahead and do all that. Let's revert this and let me show you PrepText ask. What Peter did was he wrote this little script that actually tears apart the document, it removes all the paragraph styles that what he calls neutralise, with an S in a European fashion, and then you can run PrepText yourself or any other kind of script that will automatically find local formatting and create and apply character styles, then you would come back your run perfect PrepText ask again and say now restore the text styles, that's kind of scary.
Now, I said you know can you just write me one that does both of these automatically that does the first thing, neutralizes the styles then runs PrepText, then restores the styles, and that what perfect PrepText does. Anyway there are few scripts that took a lot longer to explain than to actually run. But I know you can see how useful these scripts can be and helping you apply the right kind of text formatting to your InDesign files.
- Understanding the differences between ebook formats
- Best practices for InDesign file preparation
- Managing the content flow with Layout order and the Articles panel
- Using free InDesign scripts to automate EPUB productions
- Optimizing images, charts, and tables
- Opening and examining EPUB files
- Editing important CSS and HTML tags
- Including drop caps, pull quotes, and text wraps
- Enriching your EPUBs with video and embedded fonts
- Acquiring an ISBN for ebooks
- Converting EPUBs to Kindle format (MOBI and KF8)
- Distributing ebooks with resellers and aggregators