parseHighlightLines

Code
stable

Parse the `highlight-lines` prop of `<OrigamCode>` into a sorted, deduplicated array of 1-based line numbers. Accepts a number array, a comma/range string (e.g. `"1,3-5,7"`), or null/undefined (returns `[]`).

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

input
required
number[] | string | null | undefined
A number array, a comma- and/or range-separated string (e.g. `"1"`, `"1,3"`, `"1-3"`, `"1,3-5,7"`), or null/undefined. Whitespace inside the string is ignored. Zeros, negatives, and non-finite values are dropped silently.

API

Return value

The value returned by this util.

A sorted, deduplicated array of 1-based line numbers, or `[]` when the input is null, undefined, empty, or contains no valid numbers.

Usage

Examples

Ready-to-paste usage snippets.

Parse highlight ranges

typescript