Skip to main content

normalize_label

Function normalize_label 

Source
pub fn normalize_label(label: &str) -> String
Expand description

Normalise a refdef label per CommonMark §4.7.

  1. Strip leading and trailing whitespace.
  2. Collapse internal whitespace runs (any mixture of spaces, tabs, line endings) to a single space.
  3. Case-fold. CommonMark mandates Unicode case folding rather than plain lowercasing; the two differ for characters whose folded form is longer than the lowercased form, most notably the German sharp S ( lowercases to ß but folds to ss). We approximate by lowercasing and then expanding any remaining ß to ss — that matches the test renderer’s normalize_label and is the only multi-character fold spec.txt exercises beyond ASCII (spec example #540).