INNER CODE UNIT · TypeScript

settledTextNodes

vinta/pangu.js · src/browser/index.ts:236

    const settledTextNodes = unsettledTextNodes.map(({ node, unspaced }) => ({ node, unspaced, settled: node.data }));
    this.onTextNodesSettled?.(settledTextNodes);
  }

  private applyTextNodeSpacing(textNode: Text, unsettledTextNodes: UnsettledTextNode[]) {
    // A node the rules space again no longer holds a late fix
    this.lateFixedTextNodes.delete(textNode);
    const textNodeSpacingDecisions = decideTextNodeSpacing({
      text: textNode.data,
      previousElementLastChar: this.findPreviousElementLastChar(textNode),
      precedingNodeHidden: () => this.isPrecedingNodeHidden(textNode),
    });

    for (const textNodeSpacingDecision of textNodeSpacingDecisions) {
      switch (textNodeSpacingDecision) {
        case 'trim-leading-space':
          textNode.data = textNode.data.substring(1);
          this.lastWrittenData.set(textNode, textNode.data);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…