INNER CODE UNIT · JavaScript
measureIndent
tradingview/lightweight-charts · website/plugins/docs-markdown/index.js:456
function measureIndent(source, lineStart, limit) {
let index = lineStart;
while (index < limit && (source[index] === ' ' || source[index] === '\t')) {
index += 1;
}
if (index >= limit || source[index] === '\n' || source[index] === '\r') {
return null;
}
return index - lineStart;
}
/**
* Removes the indentation shared by every line of a JSX block's children. Only
* the common part goes, so the structure inside the block is preserved.
*
* Lines already claimed by an edit collected inside this block are ignored:
* their source is either replaced by generated Markdown or dropped, so their
* indentation says nothing about the text that will remain.