Plain text
import { glue } from "@typehug/en";
glue("I have a question.");
I have a question.
Returns a string with Unicode nonbreaking spaces. Render it as text, including in React.
Nonbreaking spaces for English and Polish.
DocumentationChange the width to see which words stay together.
I brought a notebook. We have 30 min to turn a good idea into a first draft.
I brought a notebook. We have 30 min to turn a good idea into a first draft.
6 nonbreaking spaces added
Choose the language you need. The examples below follow your selection.
npm install @typehug/enEnglish rules and the shared engine. No Polish rules included.
Pass in your text. Typehug replaces selected spaces with nonbreaking spaces.
import { glue } from "@typehug/en";
glue("I have a question.");
I have a question.
Returns a string with Unicode nonbreaking spaces. Render it as text, including in React.
import { glueHtml } from "@typehug/en/html";
glueHtml("I have a <b>question</b>.");
I have a question.
Joins across inline formatting. Importing /html loads the parser.
import { glueRuns } from "@typehug/en";
glueRuns([
{ text: "I have a " },
{ text: "question.", bold: true },
]);
I have a question.
Preserves formatting metadata and leaves the input objects unchanged.
Examples use English. With @typehug/all, pass { locale: "en" } or { locale: "pl" } as the second argument. HTML is parsed and serialized, so entity spellings and markup may normalize.
Five rule families, enabled by default. Each can be switched off.
English short-word joins and paragraph endings are editorial preferences. Typehug uses text rules, not screen measurements.
Read the rules and sources