<commit_before>import {h} from 'preact/preact';

import Util from './Util';

//COMPONENT IMPORTS
import NavLink from 'com/nav-link/link';
import AutoEmbed from 'com/autoembed/autoembed';

export default class Renderer {
  constructor(options) {
    this.options = options || {};
  }

  code(code, lang, escaped) {
    if (this.options.highlight) {
      var out = this.options.highlight(code, lang);
      if (out != null && out !== code) {
        escaped = true;
        code = out;

        return (<pre><code class={this.options.langPrefix + escape(lang, true)} dangerouslySetInnerHTML={{ __html: out}}></code></pre>);
      }
    }

    if (!lang) {
      return (
        <pre class="language-"><code>{(escaped
        ? code
        : Util.escape(code, true))}</code></pre>
      );
    }

    return (
      <pre><code class={this.options.langPrefix + escape(lang, true)}>
        {(escaped ? code : Util.escape(code, true))}
      </code></pre>
    );
  };

  blockquote(quote) {
    return (
      <blockquote>{quote}</blockquote>
    );
  };

  html(html) {
    return {html};
  };

  heading(text, level, raw) {
    const HeaderTag = `h${level}`;
    return (
      <HeaderTag id={this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-').replace(/-$/, "")}>{text}</HeaderTag>
    );
  };

  hr() {
    return (<hr/>);
  };

  list(body, ordered) {
    var Type = ordered
      ? 'ol'
      : 'ul';
    return (
      <Type>{'\n'}{body}</Type>
    );
  };

  listitem(text) {
    return (
      <li>{text}</li>
    );
  };

  paragraph(text) {
    return (
      <p>{text}</p>
    );
  };

  table(header, body) {
    return (
      <table>
        <thead>{header}</thead>
        <tbody>{body}</tbody>
      </table>
    );
  };

  tablerow(content) {
    return (
      <tr>{content}</tr>
    );
  };

  tablecell(content, flags) {
    var Type = flags.header
      ? 'th'
      : 'td';
    return (
      <Type style={"text-align:" + flags.align
        ? flags.align
        : ''}>{content}</Type>
    );
  };

  // span level renderer
  strong(text) {
    return (
      <strong>{text}</strong>
    );
  };

  em(text) {
    return (
      <em>{text}</em>
    );
  };

  emoji(text) {
    return (<img class="emoji" alt={text} title={':' + text + ':'} src={window.emoji.shortnameToURL(text)}/>);<commit_msg>Fixed emojis with _ in them<commit_after>import {h} from 'preact/preact';

import Util from './Util';

//COMPONENT IMPORTS
import NavLink from 'com/nav-link/link';
import AutoEmbed from 'com/autoembed/autoembed';

export default class Renderer {
  constructor(options) {
    this.options = options || {};
  }

  code(code, lang, escaped) {
    if (this.options.highlight) {
      var out = this.options.highlight(code, lang);
      if (out != null && out !== code) {
        escaped = true;
        code = out;

        return (<pre><code class={this.options.langPrefix + escape(lang, true)} dangerouslySetInnerHTML={{ __html: out}}></code></pre>);
      }
    }

    if (!lang) {
      return (
        <pre class="language-"><code>{(escaped
        ? code
        : Util.escape(code, true))}</code></pre>
      );
    }

    return (
      <pre><code class={this.options.langPrefix + escape(lang, true)}>
        {(escaped ? code : Util.escape(code, true))}
      </code></pre>
    );
  };

  blockquote(quote) {
    return (
      <blockquote>{quote}</blockquote>
    );
  };

  html(html) {
    return {html};
  };

  heading(text, level, raw) {
    const HeaderTag = `h${level}`;
    return (
      <HeaderTag id={this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g, '-').replace(/-$/, "")}>{text}</HeaderTag>
    );
  };

  hr() {
    return (<hr/>);
  };

  list(body, ordered) {
    var Type = ordered
      ? 'ol'
      : 'ul';
    return (
      <Type>{'\n'}{body}</Type>
    );
  };

  listitem(text) {
    return (
      <li>{text}</li>
    );
  };

  paragraph(text) {
    return (
      <p>{text}</p>
    );
  };

  table(header, body) {
    return (
      <table>
        <thead>{header}</thead>
        <tbody>{body}</tbody>
      </table>
    );
  };

  tablerow(content) {
    return (
      <tr>{content}</tr>
    );
  };

  tablecell(content, flags) {
    var Type = flags.header
      ? 'th'
      : 'td';
    return (
      <Type style={"text-align:" + flags.align
        ? flags.align
        : ''}>{content}</Type>
    );
  };

  // span level renderer
  strong(text) {
    return (
      <strong>{text}</strong>
    );
  };

  em(text) {
    return (
      <em>{text}</em>
    );
  };

  emoji(text) {
    return (<img class="emoji" alt={text} title={':' + text + ':'} src={window.emoji.shortnameToURL(text.join(''))}/>);
{'fraction_non_alphanumeric': 0.19829605963791266, 'fraction_numerical': 0.0, 'mean_word_length': 2.2054607508532422, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, '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': '7636547', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1613, 'n_words': 293}