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.
"Hello," she said, "welcome."
“Hello,” she said, “welcome.”
Single quotes quotes.single
Opening and closing single quotes, nested inside double ones.
"She said 'hi' to me."
"She said ‘hi’ to me."
Apostrophes quotes.apostrophe
Contractions, possessives and elisions: don’t, the students’, rock ’n’ roll, the ’90s.
Don't miss rock 'n' roll from the '90s.
Don’t miss rock ’n’ roll from the ’90s.
Primes quotes.primes
Feet and inches, minutes and seconds: 5′10″, 45° 30′.
He's 5'10" with a 12" record.
He's 5′10″ with a 12″ record.
Escapes quotes.escape
A backslash keeps a quote straight: \" stays ".
Type \"yes\" to confirm.
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.
Wait... what? And. . . then?
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.
One. Two . Three , four.
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.
Open Mon-Fri, 9:00-17:00, pages 10 - 20. Call 555-1234 by 2026-10-20.
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.
It was -- I think -- the best. Or so - she said - it seemed.
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.
Acme(tm) and Brand(r), (c) 2026. See option (c) below.
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.
It fell to -5 °C, a change of -12.
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.
A 1920x1080 screen, a 3 x 4 grid, address 0x1F.
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.
Add 1/2 cup, then 2 1/4 more. Due 1/2/2026.
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.
The 1st, 2nd, 3rd and 21st of May.
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.
It weighed 15 kg at 5 pm (see Fig. 3, page 12).
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.
Dr. Smith met J. R. R. Tolkien.
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.
It was—I think—fine, from 10–20.
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.
The quick brown fox jumps over the lazy dog.
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.
See https://example.com/archive/2026/10/a-long-post?ref=home for more.
See https://
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.
An extraordinarily comprehensive, unbelievably particular approach.
An extraordinarily comprehensive, unbelievably particular 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.
NASA and the BBC tested HTML5 in World War II films.
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).
Salt & pepper.
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.
The block starts here.
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.
"Quotes hang," she said, "into the margin."
"Quotes hang," she said, "into the margin."