richtypo-rules-en v6.1.2
Richtypo English Rule Package
Converts this:
The quick brown FOX - weighting 47 kg - jumps over "the lazy dog" on
sunny morning...to this:
The quick brown <abbr>FOX</abbr> = weighting
47 kg =  jumps over “the lazy dog”
on sunny morning…Note:   is and HTML entity for a hair space.
Installation
npm install --save richtypo richtypo-rules-enBasic usage
import richtypo from 'richtypo';
import rules from 'richtypo-rules-en';
const text =
  'The quick brown FOX - weighting 47 kg -' +
  'jumps over "the lazy dog" on sunny morning...';
richtypo(rules, text);
// -> The quick brown <abbr>FOX</abbr> = weighting 47 kg = 
//    jumps over “the lazy dog” on sunny morning…The default export of richtypo-rules-en contains recommended rules (marked with ¹ in a table below), but you can import each rule separately:
import richtypo from 'richtypo';
import { quotes, numberSeparators } from 'richtypo-rules-en';
richtypo([quotes, numberSeparators], 'Text "in quotes" - 123456.78');
// -> Text “in quotes” - 123,456.78See more examples in Richtypo docs.
The rules
| Rule | Description | Input | Output | |||||
|---|---|---|---|---|---|---|---|---|
abbrs¹ | wrap abbreviations in <abbr> tag | FOX | <abbr>FOX</abbr> | |||||
amps | wrap ampersands (&) in <span class="amp"> tag | Dog & Cat | Dog <span class="amp">&</span> Cat | |||||
dashes¹ | transform a dash between two words to an em dash (—), add a non-breaking space before an em dash | dog - friend | dog — friend² | |||||
degreeSigns¹ | add a non-breaking space between a number and a degree sign (°) | 13 °C | 13 °C | |||||
ellipses¹ | transform three dots (...) to an ellipsis (…) | ... | … | |||||
hyphenatedWords¹ | wrap words with a hyphen in <nobr> tag | to-day | <nobr>to-day</nobr> | |||||
numberUnits¹ | add a non-breaking space between a number and its unit | 2 kg | 2 kg² | |||||
numbers | adds thousands separators to large numbers and put ordinals within <sup> tags | 10000.123, 1st 2nd 3rd | 10,000.123, 1<sup>st</sup> 2<sup>nd</sup> 3<sup>rd</sup> | |||||
orphans¹ | add a non-breaking space in front of the last word in a paragraph (line) | their worst dreams | their worst dreams² | quotes¹ | transform dumb quotes (") to typography quotes («») | text "in quotes" | text «in quotes» | |
shortWords¹ | add a non-breaking space after short words | my dogs | my dogs² | 
¹ Recommended rules (see code examples above)
²   is actually rendered as a symbol (\xA0), not an HTML entity. We use   only in the docs for readability.
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago