<commit_before>import {
  Component,
  ViewChild,
  ElementRef,
  Input,
  Renderer
} from '@angular/core';

import hljs from 'highlight.js';
import 'highlight.js/lib/languages/python.js';
import 'highlight.js/lib/languages/sql.js';
import 'highlight.js/lib/languages/javascript.js';
import 'highlight.js/lib/languages/yaml.js';
import 'highlight.js/lib/languages/powershell.js';
import 'highlight.js/styles/atom-one-dark.css';

/**
 * Component for highlighting code syntax
 * Inspired by: https://github.com/Teradata/covalent/tree/cf9e24343c185ff2c5db2de0b797b536d6072e21/src/platform/highlight
 */
@Component({
  selector: 'code-highlight',
  template: `
    <pre><code #highlight><ng-content></ng-content></code></pre>
  `
})
export class CodeHighlight {

  @Input() language = 'javascript';
  @Input() json;

  @ViewChild('highlight') content;

  constructor(renderer: Renderer) {
    this.renderer = renderer;
  }

  ngOnChanges(change) {
    if(change.json && change.json.currentValue) {
      const value = change.json.currentValue;
      const str = JSON.stringify(value, null, ' ');
      this.prettify(str);
    }
  }

  ngAfterViewInit() {
    this.element = this.content.nativeElement;
    this.renderer.detachView([].slice.call(this.element.childNodes));
    this.prettify(this.element.innerHTML);
  }

  prettify(contents) {
    // ensure load
    if(!this.element) return;

    let lines = contents.split('\n');

    // Remove empty lines
    lines = lines.filter(function(line) {
      return line.trim().length > 0;
    });

    // don't mess w/ empties
    if(!lines.length) return;

    // Make it so each line starts at 0 whitespace
    let firstLineWhitespace = lines[0].match(/^\s*/)[0];<commit_msg>(bug): fix code highlighter broken after refactor for json data<commit_after>import {
  Component,
  ViewChild,
  ElementRef,
  Input,
  Renderer
} from '@angular/core';

import hljs from 'highlight.js';
import 'highlight.js/lib/languages/python.js';
import 'highlight.js/lib/languages/sql.js';
import 'highlight.js/lib/languages/javascript.js';
import 'highlight.js/lib/languages/yaml.js';
import 'highlight.js/lib/languages/powershell.js';
import 'highlight.js/styles/atom-one-dark.css';

/**
 * Component for highlighting code syntax
 * Inspired by: https://github.com/Teradata/covalent/tree/cf9e24343c185ff2c5db2de0b797b536d6072e21/src/platform/highlight
 */
@Component({
  selector: 'code-highlight',
  template: `
    <pre><code #highlight><ng-content></ng-content></code></pre>
  `
})
export class CodeHighlight {

  @Input() language = 'javascript';
  @Input() json;

  @ViewChild('highlight') content;

  constructor(renderer: Renderer) {
    this.renderer = renderer;
  }

  ngOnChanges(change) {
    if(change.json && change.json.currentValue) {
      const value = change.json.currentValue;
      const str = JSON.stringify(value, null, ' ');
      this.prettify(str);
    }
  }

  ngAfterViewInit() {
    this.element = this.content.nativeElement;
    const code = this.element.innerHTML;
    this.renderer.detachView([].slice.call(this.element.childNodes));
    this.prettify(code);
  }

  prettify(contents) {
    // ensure load
    if(!this.element) return;

    let lines = contents.split('\n');

    // Remove empty lines
    lines = lines.filter(function(line) {
      return line.trim().length > 0;
    });

    // don't mess w/ empties
    if(!lines.length) return;

    // Make it so each line starts at 0 whitespace
    let firstLineWhitespace = lines[0].match(/^\s*/)[0];
{'fraction_non_alphanumeric': 0.14984361671879443, 'fraction_numerical': 0.016491327836224055, 'mean_word_length': 3.6167979002624673, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 2, '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': '6072485', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1152, 'n_words': 215}