<commit_before>import {h, Component} from 'preact';
import './Main.css';
import {compilePugTemplate} from '../api';
import debounce from 'debounce';

import * as ace from 'brace';
import 'brace/mode/jade';
import 'brace/mode/html';
import 'brace/theme/monokai';
import {html as htmlBeautify} from 'js-beautify';

export default class extends Component {
  state = {output: ''};

  autoProcess = e => {
    let source = this.sourceEditor.getValue();
    this.process(source);
  }

  process = async (source) => {
    if(!source){
      this.outputEditor.setValue('');  
      return;
    }
    let res = await compilePugTemplate(source);
    this.outputEditor.setValue(htmlBeautify(res.out));
    this.outputEditor.clearSelection();
  }

  componentDidMount() {
    const process = debounce(this.autoProcess, 500);
    const sourceEditor = ace.edit('sourceEditor');
    sourceEditor.getSession().setMode('ace/mode/jade');
    sourceEditor.getSession().setTabSize(2);
    sourceEditor.setTheme('ace/theme/monokai');

    this.sourceEditor = sourceEditor;

    sourceEditor.on('change', process);
    sourceEditor.on('paste', process);

    const outputEditor = ace.edit('outputEditor');
    outputEditor.getSession().setMode('ace/mode/html');
    outputEditor.setTheme('ace/theme/monokai');
    outputEditor.setReadOnly(true);
    this.outputEditor = outputEditor;
  }
  
  render(){
    return(
      <div class="mdc-typography">
        <header class="mdc-toolbar">
          <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
            <a class="material-icons">menu</a>
            &nbsp;&nbsp;&nbsp;
            <span class="mdc-toolbar__title">PUG to HTML Online</span>
          </section>
          <section class="mdc-toolbar__section mdc-toolbar__section--align-end">
            <a class="mdc-button mdc-button--raised mdc-button--primary" href="">GITHUB</a>
          </section>
        </header><commit_msg>Update the github link<commit_after>import {h, Component} from 'preact';
import './Main.css';
import {compilePugTemplate} from '../api';
import debounce from 'debounce';

import * as ace from 'brace';
import 'brace/mode/jade';
import 'brace/mode/html';
import 'brace/theme/monokai';
import {html as htmlBeautify} from 'js-beautify';

export default class extends Component {
  state = {output: ''};

  autoProcess = e => {
    let source = this.sourceEditor.getValue();
    this.process(source);
  }

  process = async (source) => {
    if(!source){
      this.outputEditor.setValue('');  
      return;
    }
    let res = await compilePugTemplate(source);
    this.outputEditor.setValue(htmlBeautify(res.out));
    this.outputEditor.clearSelection();
  }

  componentDidMount() {
    const process = debounce(this.autoProcess, 500);
    const sourceEditor = ace.edit('sourceEditor');
    sourceEditor.getSession().setMode('ace/mode/jade');
    sourceEditor.getSession().setTabSize(2);
    sourceEditor.setTheme('ace/theme/monokai');

    this.sourceEditor = sourceEditor;

    sourceEditor.on('change', process);
    sourceEditor.on('paste', process);

    const outputEditor = ace.edit('outputEditor');
    outputEditor.getSession().setMode('ace/mode/html');
    outputEditor.setTheme('ace/theme/monokai');
    outputEditor.setReadOnly(true);
    this.outputEditor = outputEditor;
  }
  
  render(){
    return(
      <div class="mdc-typography">
        <header class="mdc-toolbar">
          <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
            <a class="material-icons">menu</a>
            &nbsp;&nbsp;&nbsp;
            <span class="mdc-toolbar__title">PUG to HTML Online</span>
          </section>
          <section class="mdc-toolbar__section mdc-toolbar__section--align-end">
            <a class="mdc-button mdc-button--raised mdc-button--primary" href="https://github.com/shidhincr/pug-to-html">GITHUB</a>
          </section>
        </header>
{'fraction_non_alphanumeric': 0.15001271294177473, 'fraction_numerical': 0.0020340706839562673, 'mean_word_length': 3.415263748597082, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 33, 'https://': 1, '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': '4500531', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1195, 'n_words': 222}