<commit_before>import {format as formatPoint} from '../../src/point-helpers'
import Patch from '../../src/patch'
import Node from '../../src/node'

Patch.prototype.toHTML = function () {
  if (this.root) {
    return this.root.toHTML()
  } else {
    return ''
  }
}

Node.prototype.toHTML = function () {
  let s = '<style>';
  s += 'table { width: 100%; }';
  s += 'td { width: 50%; text-align: center; border: 1px solid gray; white-space: nowrap; }';
  s += '</style>';

  s += '<table>';

  s += '<tr>';

  let changeStart = this.isChangeStart ? '&lt;&lt; ' : '';
  let changeEnd = !this.isChangeStart ? ' &gt;&gt;' : '';

  s += '<td colspan="2">' + changeStart + formatPoint(this.inputLeftExtent) + ' / ' + formatPoint(this.outputLeftExtent) + changeEnd + '</td>';
  s += '</tr>';

  if (this.left || this.right) {
    s += '<tr>';
    s += '<td>';
    if (this.left) {
      s += this.left.toHTML();
    } else {
      s += '&nbsp;';
    }
    s += '</td>';
    s += '<td>';
    if (this.right) {
      s += this.right.toHTML();
    } else {
      s += '&nbsp;';
    }
    s += '</td>';
    s += '</tr>';
  }

  s += '</table>';

  return s;
}<commit_msg>Print absolute positions of nodes in HTML output<commit_after>import {ZERO_POINT, traverse, format as formatPoint} from '../../src/point-helpers'
import Patch from '../../src/patch'
import Node from '../../src/node'

Patch.prototype.toHTML = function () {
  if (this.root) {
    return this.root.toHTML()
  } else {
    return ''
  }
}

Node.prototype.toHTML = function (leftAncestorInputPosition = ZERO_POINT, leftAncestorOutputPosition = ZERO_POINT) {
  let s = '<style>';
  s += 'table { width: 100%; }';
  s += 'td { width: 50%; text-align: center; border: 1px solid gray; white-space: nowrap; }';
  s += '</style>';

  s += '<table>';

  s += '<tr>';
  let changeStart = this.isChangeStart ? '&lt;&lt; ' : '';
  let changeEnd = !this.isChangeStart ? ' &gt;&gt;' : '';
  let inputPosition = traverse(leftAncestorInputPosition, this.inputLeftExtent)
  let outputPosition = traverse(leftAncestorOutputPosition, this.outputLeftExtent)
  s += '<td colspan="2">' + changeStart + formatPoint(inputPosition) + ' / ' + formatPoint(outputPosition) + changeEnd + '</td>';
  s += '</tr>';

  if (this.left || this.right) {
    s += '<tr>';
    s += '<td>';
    if (this.left) {
      s += this.left.toHTML(leftAncestorInputPosition, leftAncestorOutputPosition);
    } else {
      s += '&nbsp;';
    }
    s += '</td>';
    s += '<td>';
    if (this.right) {
      s += this.right.toHTML(inputPosition, outputPosition);
    } else {
      s += '&nbsp;';
    }
    s += '</td>';
    s += '</tr>';
  }

  s += '</table>';

  return s;
}
{'fraction_non_alphanumeric': 0.2175529936779472, 'fraction_numerical': 0.005206396429899591, 'mean_word_length': 2.804809052333805, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4874207', 'n_tokens_mistral': 963, 'n_tokens_neox': 939, 'n_words': 223}