Smarten Punctuation

Smarten Punctuation converts plain punctuation in XHTML text into typographic punctuation. It is intended for ordinary prose text and skips code-like elements such as script, style, code, pre, kbd, samp, and var.

Current file or whole book

Use the toolbar menu to choose whether the tool processes only the current XHTML file or all XHTML files in the book. Whole-book processing is useful after import or OCR cleanup; current-file processing is safer when testing settings.

Quotation marks

When Smarten quotation marks is enabled, straight quotation marks are converted into curly quotation marks according to the selected output mode.

Example:

"Hello," she said.

can become:

“Hello,” she said.

Dashes

The dash setting controls how double and triple hyphens are converted.

Choose the convention that matches the source text. If the book already mixes dash styles, review the diff carefully.

Smarten Punctuation converts hyphen sequences into dashes. It does not adjust the spacing around a dash that is already there. Use Cleanup if you want to normalize parenthetical dash spacing, or to attach dashes to the preceding word.

Ellipses

When Smarten ellipses is enabled, compact and spaced-dot ellipses are converted. Recognized forms include ..., . . ., ...., and . . . .. The conversion uses the ellipsis character … with Unicode output, or … with entity output; it does not produce Chicago-style spaced periods with non-breaking spaces.

Unicode or entities

With Unicode output enabled, punctuation is written as characters such as “, ’, —, and …. With entity output, the punctuation and spacing characters the tool introduces are written as numeric HTML character references instead, for example “ and …. Named entities such as “ are not produced. Unicode is usually easier to read and edit. Entity output can be useful for projects that require entity-based punctuation.

Escaped entity text

Text that displays an entity rather than using one is left exactly as written. For example, source markup containing   appears to the reader as the literal text  . This matters for technical books and documentation that quote entity syntax on purpose.

Apostrophe exception rules

The apostrophe exception file is shared with Cleanup. Enable Apply apostrophe exception rules before smartening when a project has words that the normal smartening engine may interpret incorrectly.

Rules use an explicit mapping format:

@em -> ’em
@tis -> ’tis
rock @n@ roll -> rock ’n’ roll

The @ marker means an apostrophe must already be present in the source at that position. For example, @em -> ’em fixes 'em, ‘em, and ’em, but does not change the plain word em.

Smarten Punctuation also protects abbreviated years before smartening, so common forms such as class of '79, '68 Mustang, and the '90s use closing apostrophes.

Smarten Punctuation treats quote-adjacent whitespace as transparent when deciding quote direction, while preserving the original spacing in the output. This helps nested forms such as " 'word' " or curly quotes separated by a hair space smarten correctly without deleting the spacing.

Punctuation split by markup

When markup divides a word, as in <em>John</em>'s, the apostrophe begins a separate piece of text and a simple smartening pass would treat it as an opening quote. Smarten Punctuation checks the preceding text and produces a closing apostrophe instead, for recognised suffixes such as 's, 're, 've, 'll, 'd, and 'm.

Reviewing changes

Smarten Punctuation is powerful, but punctuation changes are editorial changes. Use Calibre's diff viewer after processing, especially when running across the whole book.