packages/web/src/routes/docs/harperjs/spans/+page.md
When you lint a document using harper.js, you'll get back a series of Lint objects, each with a span method available.
There are a number of questions that come up about this method.
A span is a struct that contains a start index and an end index. The Rust code looks something like this:
struct Span {
start: usize,
end: usize
}
For the uninitiated, a usize is an unsigned integer.
Most commonly (and always in the context of a Lint), spans are referring to character windows.
More precisely, spans are windows or slices into an array of unicode scalar values.
This is less relevant to JavaScript consumers.
Some get confused and believe these are indices into byte arrays (C-style strings).
The actual span for a Lint is stored inside WebAssembly memory.
In order to access that data from JavaScript, a tiny bit of WebAssembly code must be run to serialize it and convert its indices to JavaScript number types.
In a Lint, the span represents two things:
In other words, you use the span to underline the problem, then again to solve it.