Rules

Every rule is on by default. Each has an id, and so does each group: pass either in disable to turn it off, e.g. setwell(html, { disable: ["marks.hanging", "hyphenate"] }). Rules run one after another, each seeing the text as the ones before left it: characters first, then line breaks and hyphens, then spans. Each example below shows one rule on its own.

Quotes quotes

Straight quotes become curly ones, paired across inline tags, with apostrophes and primes told apart.

Double quotes quotes.double

Opening and closing double quotes, including ones split across tags.

Before

"Hello," she said, "welcome."

After

“Hello,” she said, “welcome.”

Single quotes quotes.single

Opening and closing single quotes, nested inside double ones.

Before

"She said 'hi' to me."

After

"She said ‘hi’ to me."

Apostrophes quotes.apostrophe

Contractions, possessives and elisions: don’t, the students’, rock ’n’ roll, the ’90s.

Before

Don't miss rock 'n' roll from the '90s.

After

Don’t miss rock ’n’ roll from the ’90s.

Primes quotes.primes

Feet and inches, minutes and seconds: 5′10″, 45° 30′.

Before

He's 5'10" with a 12" record.

After

He's 5′10″ with a 12″ record.

Escapes quotes.escape

A backslash keeps a quote straight: \" stays ".

Before

Type \"yes\" to confirm.

After

Type "yes" to confirm.

Dashes & punctuation punctuation

Dashes for what they mean, ellipses, symbols, and stray spaces.

Ellipsis punctuation.ellipsis

Three full stops become one ellipsis character.

Before

Wait... what? And. . . then?

After

Wait… what? And… then?

Space cleanup punctuation.spaceCleanup

Two spaces after a sentence become one; a stray space before a comma or full stop goes.

Before

One. Two . Three , four.

After

One. Two. Three, four.

Range dashes punctuation.enDashRange

Number and day ranges get an unspaced en dash. Dates, phone numbers and longer chains are left alone.

Before

Open Mon-Fri, 9:00-17:00, pages 10 - 20. Call 555-1234 by 2026-10-20.

After

Open Mon–Fri, 9:00–17:00, pages 10–20. Call 555-1234 by 2026-10-20.

Em dashes punctuation.emDash

Double and triple hyphens, and a spaced hyphen between words, become an em dash.

Before

It was -- I think -- the best. Or so - she said - it seemed.

After

It was—I think—the best. Or so—she said—it seemed.

Symbols punctuation.symbols

© before a year, ™ and ® straight after a word. A list marker like (c) stays as it is.

Before

Acme(tm) and Brand(r), (c) 2026. See option (c) below.

After

Acme™ and Brand®, © 2026. See option (c) below.

Numbers numbers

The right characters for numbers, and ordinals ready for superscript.

Minus sign numbers.minus

A hyphen before a number becomes a true minus sign, which is as wide as a plus.

Before

It fell to -5 °C, a change of -12.

After

It fell to −5 °C, a change of −12.

Multiplication sign numbers.times

1920x1080 and 3 x 4 get a proper ×. Hex like 0x1F is left alone.

Before

A 1920x1080 screen, a 3 x 4 grid, address 0x1F.

After

A 1920×1080 screen, a 3 × 4 grid, address 0x1F.

Fractions numbers.fractions

Fractions Unicode has a character for (½, ¾, ⅛, …). Dates like 1/2/2026 are left alone.

Before

Add 1/2 cup, then 2 1/4 more. Due 1/2/2026.

After

Add ½ cup, then 2¼ more. Due 1/2/2026.

Ordinals numbers.ordinals

The suffix of 1st, 22nd and 103rd in a span, styled smaller and raised.

Before

The 1st, 2nd, 3rd and 21st of May.

After

The 1st, 2nd, 3rd and 21st of May.

Line breaks breaks

Non-breaking spaces and break points, so lines end in sensible places.

Numbers and units breaks.numbersUnits

10 kg, 5 pm, $ 5, page 12, Fig. 3: a number stays on the line with its unit or label.

Before

It weighed 15 kg at 5 pm (see Fig. 3, page 12).

After

It weighed 15 kg at 5 pm (see Fig. 3, page 12).

  no-break space — lines never break there.

Names breaks.honorifics

Dr. Smith, Mr Jones, J. R. R. Tolkien: titles and initials stay with the name.

Before

Dr. Smith met J. R. R. Tolkien.

After

Dr. Smith met J. R. R. Tolkien.

  no-break space — lines never break there.

Dashes breaks.dashes

An em dash never starts a line, and a range never breaks after its dash.

Before

It was—I think—fine, from 10–20.

After

It was⁠—I think⁠—fine, from 10–⁠20.

⁠ word joiner — lines never break there.

Widows breaks.widows

The last two words of a paragraph are joined, if they're short, so the last line is never one lonely word.

Before

The quick brown fox jumps over the lazy dog.

After

The quick brown fox jumps over the lazy dog.

  no-break space — lines never break there.

URLs breaks.urls

Long URLs and email addresses get break points after slashes and before dots, so they wrap on phones.

Before

See https://example.com/archive/2026/10/a-long-post?ref=home for more.

After

See https://example.com/archive/2026/10/a-long-post?ref=home for more.

Hyphenation hyphenate

Soft hyphens in long words, invisible until a line breaks there.

Soft hyphens hyphenate.soft

US English hyphenation (TeX’s patterns) in lowercase words of six letters or more. Names, URLs, code-like words and headings are left whole.

Before

An extraordinarily comprehensive, unbelievably particular approach.

After

An extra­or­di­nar­ily com­pre­hen­sive, unbe­liev­ably par­tic­u­lar approach.

Spans for CSS marks

Small spans that setwell.css styles: things only CSS can finish.

Small caps marks.smallCaps

Acronyms (NASA, HTML5, U.S.) as slightly smaller capitals, so they don't shout. Roman numerals, headings and all-caps text are left alone.

Before

NASA and the BBC tested HTML5 in World War II films.

After

NASA and the BBC tested HTML5 in World War II films.

Ampersands marks.ampersand

A free-standing & in a span, for sites that want to style it (unstyled by default).

Before

Salt & pepper.

After

Salt & pepper.

Optical letters marks.opticalLetters

A block that starts with T, V, W, Y, O, C, G, Q or A is nudged left, so its edge looks aligned.

Before

The block starts here.

After

The block starts here.

Hanging punctuation marks.hanging

Opening quotes hang into the margin at the start of a line, and stay in place mid-line.

Before

"Quotes hang," she said, "into the margin."

After

"Quotes hang," she said, "into the margin."