{
const processor = retext();
const tree = processor.parse(inputText);
await processor.run(tree);
let sentences = [];
visit(tree, "SentenceNode", function(node) {
sentences.push(node);
});
const maxLength = d3.max(sentences, function(sentence) {
return sentence.position.end.offset - sentence.position.start.offset;
});
return styledNLCST(tree, (node, tree) => {
if (node.type === "SentenceNode") {
const length = node.position.end.offset - node.position.start.offset;
const color = d3
.scaleSequential(d3.interpolateGreys)
.domain([0, maxLength])(length);
return `background-color: ${color}; color: transparent;`;
}
});
}