<commit_before># encoding=utf-8
require 'spec_helper'

describe Polytexnic::Core do
  it { should respond_to(:polytex_to_html_fragment) }

  describe '#polytex_to_html' do
    subject { Polytexnic::Core.polytex_to_html_fragment(polytex) }

    describe "italics conversion" do
      let(:polytex) { '\emph{foo bar}' }
      it { should resemble('<em>foo bar</em>') }
    end

    describe "with multiple instances" do
      let(:polytex) do
        '\emph{foo bar} and also \emph{baz quux}'
      end

      it { should resemble('<em>foo bar</em>') }
      it { should resemble('<em>baz quux</em>') }
    end

    describe "quoted strings" do
      context "with single quotes" do
        let(:polytex) { "``foo bar''" }
        it { should =~ /&#8220;foo bar&#8221;/ }
      end
    end

    describe "footnotes" do
      let(:polytex) { '\footnote{Foo}' }
      it do
        should resemble('<a class="footnote-number" href="#footnote-1">1</a>')
      end
      it do
        should resemble(
          '<div id="footnotes">' +
            '<div id="footnote-1" class="footnote">Foo</div>' +
          '</div>'
        )
      end
    end

    describe "LaTeX logo" do
      let(:polytex) { '\LaTeX' }
      it { should resemble('<span class="LaTeX"></span>') }
    end

    describe '\ldots' do
      let(:polytex) { '\ldots' }
      it { should resemble('...') }
    end

    describe 'end-of-sentence punctuation' do
      let(:polytex) { 'Superman II\@. Lorem ipsum.' }
      it { should resemble('Superman II. Lorem ipsum.') }
    end

    describe 'unbreakable interword space' do
      let(:polytex) { 'foo~bar' }
      it { should resemble('foo&#160;bar') }
    end

    describe "verbatim environments" do
       let(:polytex) do <<-'EOS'
\begin{verbatim}
  \emph{foo bar}<commit_msg>[Delivers #45100705] Test for \ldots to &#133;<commit_after># encoding=utf-8
require 'spec_helper'

describe Polytexnic::Core do
  it { should respond_to(:polytex_to_html_fragment) }

  describe '#polytex_to_html' do
    subject { Polytexnic::Core.polytex_to_html_fragment(polytex) }

    describe "italics conversion" do
      let(:polytex) { '\emph{foo bar}' }
      it { should resemble('<em>foo bar</em>') }
    end

    describe "with multiple instances" do
      let(:polytex) do
        '\emph{foo bar} and also \emph{baz quux}'
      end

      it { should resemble('<em>foo bar</em>') }
      it { should resemble('<em>baz quux</em>') }
    end

    describe "quoted strings" do
      context "with single quotes" do
        let(:polytex) { "``foo bar''" }
        it { should =~ /&#8220;foo bar&#8221;/ }
      end
    end

    describe "footnotes" do
      let(:polytex) { '\footnote{Foo}' }
      it do
        should resemble('<a class="footnote-number" href="#footnote-1">1</a>')
      end
      it do
        should resemble(
          '<div id="footnotes">' +
            '<div id="footnote-1" class="footnote">Foo</div>' +
          '</div>'
        )
      end
    end

    describe "LaTeX logo" do
      let(:polytex) { '\LaTeX' }
      it { should resemble('<span class="LaTeX"></span>') }
    end

    describe '\ldots' do
      let(:polytex) { '\ldots' }
      it { should resemble('&#133;') }
    end

    describe 'end-of-sentence punctuation' do
      let(:polytex) { 'Superman II\@. Lorem ipsum.' }
      it { should resemble('Superman II. Lorem ipsum.') }
    end

    describe 'unbreakable interword space' do
      let(:polytex) { 'foo~bar' }
      it { should resemble('foo&#160;bar') }
    end

    describe "verbatim environments" do
       let(:polytex) do <<-'EOS'
\begin{verbatim}
  \emph{foo bar}
{'fraction_non_alphanumeric': 0.15187431091510475, 'fraction_numerical': 0.012127894156560088, 'mean_word_length': 2.4529019980970506, 'pattern_counts': {'":': 0, '<': 35, '<?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': '5422128', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1172, 'n_words': 303}