<commit_before>/* eslint-disable no-use-before-define */
import * as hh from '../src/main';

import bootstrap from './bootstrap';
import { data } from './tests';
import * as attest from './attest';
import html from './html/index.html';

bootstrap(html);

// Test-wide attributes
let container;
let instance;

function init(ndx) {
  // Ensure window and document exist in jsdom environment
  if (window == null || document == null || document.body == null) {
    throw new Error('DOM environment not available');
  }

  if (container) {
    container.remove();
  }

  container = document.createElement('div');
  container.innerHTML = data[ndx || 0];
  container.style.position = 'absolute';
  container.style.top = '-200%';
  container.style.left = '-200%';
  document.body.appendChild(container);

  instance = new hh.HtmlHighlighter(getOptions());
  attest.clear();

  return instance;
}

function getOptions() {
  return { container, maxHighlight: 100 };
}

function get(what) {<commit_msg>test: run HTML Highlighter in debug mode<commit_after>/* eslint-disable no-use-before-define */
import * as hh from '../src/main';

import bootstrap from './bootstrap';
import { data } from './tests';
import * as attest from './attest';
import html from './html/index.html';

bootstrap(html);

// Test-wide attributes
let container;
let instance;

// Switch to debug mode
hh.HtmlHighlighter.debug = true;

function init(ndx) {
  // Ensure window and document exist in jsdom environment
  if (window == null || document == null || document.body == null) {
    throw new Error('DOM environment not available');
  }

  if (container) {
    container.remove();
  }

  container = document.createElement('div');
  container.innerHTML = data[ndx || 0];
  container.style.position = 'absolute';
  container.style.top = '-200%';
  container.style.left = '-200%';
  document.body.appendChild(container);

  instance = new hh.HtmlHighlighter(getOptions());
  attest.clear();

  return instance;
}

function getOptions() {
  return { container, maxHighlight: 100 };
}

function get(what) {
{'fraction_non_alphanumeric': 0.14920328343795267, 'fraction_numerical': 0.009657170449058426, 'mean_word_length': 3.8867924528301887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1826465', 'n_tokens_mistral': 635, 'n_tokens_neox': 608, 'n_words': 180}