API reference › @evolu/common › Leancase

Experimental

Leancase, a minimal writing style as a normal form.

Leancase marks each boundary once. A line break already ends a sentence, so a final period repeats it. A period between sentences already starts the next one, so a capital letter repeats it. Leancase drops the repeats and, for a uniform look, every other capital letter too:

  • Everything is lowercase, including sentence starts, names, acronyms, and the pronoun I.
  • Code in backticks or a code fence, URLs with a scheme, @handles, and #hashtags keep their case, because changing it can break them or change their meaning.
  • A line that ends a sentence has no final period, but an ellipsis stays. Periods between sentences on the same line stay.
  • Nothing else changes: wording, other punctuation, whitespace, and line breaks stay.

leancase converts plain text, such as a post or a chat message, where every line break is a visible one. Converting leancase text again changes nothing, so leancase text is exactly the text leancase leaves unchanged, and LeancasedString validates it that way.

Markdown is not supported. A soft line break inside a Markdown paragraph renders as a space, so removing the period before it would merge two sentences.

Leancase is experimental. Its rules may change in a minor or patch release.

Example

import { assertEqual, leancase } from "@evolu/common";

const docs = "https://evolu.dev/docs/api-reference/common/Leancase";

assertEqual(
  leancase(`I like Evolu. See ${docs}.\nThanks, @Steida.`),
  `i like evolu. see ${docs}\nthanks, @Steida`,
);

Functions

FunctionDescription
leancaseConverts plain text to leancase and returns a LeancasedString.

Interfaces

InterfaceDescription
LeancasedErrorError returned when leancased rejects a string.

Type Aliases

Type AliasDescription
LeancasedStringA String in leancase.

Variables

VariableDescription
leancasedAdds leancase validation to an existing string Type.
LeancasedStringA String in leancase.