Latest update 6/17/2018
Projects designed for print include formatting not suitable for websites, requiring adjustments to the document prior to, or editing HTML after, exporting or pasting content from the document. This script automates common adjustments, and is equally useful when converting documents to e-books. Unwanted formatting is resolved in one operation rather than repeated visits to the InDesign Find/Change dialog.
- Apply to entire document, selected story, or selected text
- Confirmation to proceed, undo, or skip each change
- Remove forced line breaks
- Remove excess at line, paragraph, and story ends
- Remove excess spaces
- Change tabs to spaces
- Remove empty paragraphs
- Remove zero-width characters
- Remove column/frame/page breaks
- Fix flopped apostrophes
- Fix foot and inch marks
- Remove forced capitalization/change letter case
- Save and restore all settings
Free to download and use. Contributions of any amount are appreciated but not required.
Instructions for use
The interface is divided into three sections: Search, Options, and Settings. Enable desired options and click the OK button to begin. Each task (option selected) is performed in the order listed on screen.
The Scripts palette is closed to give a clear view of the layout, and the display is magnified to better show the changes to confirm. Also, Show Hidden Characters is enabled and the display mode is changed to Normal. After processing is complete, all prior view settings are restored.
The first match discovered is selected in the layout and a confirmation dialog appears on screen. A description of the proposed change is displayed above a series of buttons:
Confirm — the selected text is changed and displayed. The button Confirm becomes OK and the former button OK becomes Undo. The remaining buttons other than Cancel are disabled. Click OK to continue as described below. Undo reverts the change and restores the prior confirmation dialog, where Skip may be chosen instead, if desired.
OK — (for either confirmation dialog) the selected text is changed as indicated, and the next proposed change is selected.
OK all — the selected text and all remaining matching instances are changed without further user intervention. This applies only to the current task (tasks defined as options selected). When processing of the next task begins, the confirmation dialog is again displayed. This repeats until all selected tasks are completed.
Skip — the selected text is not changed, and the next proposed change is selected.
Skip all — the selected text is not changed and all remaining matching instances are ignored. Processing resumes with the next task and again the confirmation dialog is displayed.
Cancel — processing ceases without further changes. Any changes previously accepted remain. If desired, the Edit menu item Undo restores the document to its state prior to launching the script.
The confirmation dialog appears centered on screen and near the top of the window. If the dialog obscures the layout, it may be moved to another location on screen, even to a secondary display. The dialog will maintain its new position until the next launch of the script.
If any story has overset text, it is not possible to show the proposed change because it is hidden off-screen in the overset text. In this case, a warning is displayed and the user has the option to continue regardless, or decline and remedy the overset text before trying again, the recommended choice. Then each change is visible and can be confirmed.
If not canceled, the user is notified when processing is complete.
Section 1: Search
Document — changes apply to the entire document that is currently open and the top-most window if multiple documents are open.
Story — changes apply to the selected story. If no story is selected, the choice is disabled. The user may also choose Document to increase the scope of text affected.
Selection — changes apply to the selected text. If no text is selected, the choice is disabled. The user may also choose Story or Document to increase the scope of text affected.
Zoom — the percentage to which the display is magnified when processing begins. This allows the user a closer look at selected text to better judge if changes are acceptable.
Section 2: Options
Remove forced line breaks — forced line breaks are removed, which otherwise add ‘<br />’ tags to HTML output. If the tag is desired, skip the change. The script determines if a space character or a hyphen precedes or follows each line break, and for instances where both are absent, the line break is changed to a space to prevent words from crashing together.
Remove excess at line, paragraph, and story ends —spaces and tabs preceding forced line breaks or paragraph ends are removed. For stories, the same applies and includes forced line breaks and paragraph ends at the story end. If one or more paragraph ends exist at the story end, one paragraph end will remain, otherwise the story concludes with a story end marker. Note: excess at story end task ignored for stories that contain tables (not currently compatible).
Remove spaces at paragraph begin —space characters at the beginning of paragraphs are removed.
Change special spaces to normal space —special space characters are changed to normal space characters. Examples of special space characters are non-breaking, thin, en, and em spaces, among others.
Change tabs to space —tab characters are changed to a space character.
Change multiple spaces to single space —two or more consecutive space characters are reduced to a single space. Excess spaces otherwise add ‘ ’ tags to HTML output.
Remove empty paragraphs — empty paragraphs are removed, which otherwise add ‘<p> </p>’ to HTML output.
Remove zero-width characters — removes various marker characters, such as index, joiner/non-joiner, and others evident only when Show Hidden Characters is enabled. For text imported from a word processing program, these usually have a different meaning and once brought into InDesign, they are excess. Furthermore, these characters do not apply to web pages or e-books, and in fact may become characters of a width greater than zero, upsetting dynamic text. Therefore it is wise to remove them all.
Remove column/frame/page breaks — removes these break characters, which have no meaning to a web page or e-book.
Remove hyphens (must confirm) —hyphens are selected for removal. Unique to this option, when the confirmation dialog appears, OK and OK all are disabled, as every case of hyphen removal should be confirmed. Usually hyphens are part of the content (i.e. ‘well-lit’) but also hyphens can be used to force hyphenation and break a line in the layout. If undetected and the document is repurposed for a website, cases of forced hyphenation become errors (i.e. ‘win-dow’). This option helps spot them. Confirm and remove any hyphens that do not belong.
Fix flopped apostrophes — InDesign and word processing programs feature auto-correct that converts single and double quotation marks to “typographer’s quotes.” In most cases this is helpful, but in the rare case a word begins with an apostrophe, this auto-correct feature errantly changes the apostrophe to an opening (left) single quotation mark. For example, go get ’em or summer of ’88 are changed to an opening single quotation mark, the mirror image of an apostrophe (in other words, flopped). This option detects such cases and lets the user change to the correct closing (right) mark, which doubles as an apostrophe.
Fix foot and inch marks — like flopped apostrophes, InDesign and word processing programs errantly change foot and inch marks to typographer’s quotes. This option detects single or double quotation marks that follow a digit, and allows changing these to a single or double straight quotation, the proper symbol for feet or inches.
Remove forced capitalization/change letter case — text assigned All Caps or Small Caps is changed to Normal capitalization. Unique to this option, the confirm button displays additional buttons to change letter case of the selected text.
For example, native text ‘thE tiTLe’ when assigned All Caps, obscures the fact the case is mixed. To resolve this flaw, click the button for the desired letter case. As well, selected text may need adjustment to title or sentence case based on context. The added buttons allow the user to adjust each instance as needed, at the same time forced capitalization is being removed.
Section 5: Settings
The current options may be saved and restored later. Select from the Load drop-down list to choose saved settings, which then updates the current options. Click the Delete button and the saved settings selected in the Load drop-down list are permanently removed. Click the Save button, provide a name for the settings, and the current options are preserved. If the name already exists, the user may choose to replace the saved settings.
The script provides default saved settings named [Default]. These settings cannot be deleted but may be updated to any desired values by saving settings and providing the name [Default], which then overwrites the default settings.
Each time processing begins, the current options are preserved, and the next time the script is launched, options are restored to the last values used. Zoom value is not included in saved settings, but is preserved so that each launch of the script, the last value used is restored.
The functionality to save settings requires a file to store the settings, which coexists in the script folder alongside the script file itself. It has the same name as the script but a different extension, “json”. The file may or may not be visible depending on the InDesign Scripts Panel option Display unsupported files. Normally only script files are visible, but when this option is enabled in the Script Panel fly-out menu, all files are visible.
- Try/catch for closing scripts panel. Otherwise unhandled exception in some foreign languages.
- Added option remove zero-width characters.
- Added option remove column/frame/page breaks.
- Added option fix foot and inch marks.
- Fix excess story end error when story is a single character.
- Fix empty paragraphs flaw when story is a single character.
- Fix empty paragraphs flaw, now exclude frame and page breaks.
- Revise empty paragraphs option logic.
- Fix excess story end error when text is within table cell.
- Disable excess story end option when a selection.
- Catch processing errors and alert user.
- Add option fix flopped apostrophes.
For help installing scripts, see How to install and use scripts in Adobe Creative Cloud applications.
IMPORTANT: by downloading the script you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.