# encoding=utf-8 require 'spec_helper' describe 'Polytexnic::Pipeline#to_html' do subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html } describe "comments" do let(:polytex) { "% A LaTeX comment" } it { should eq '' } context "occurring a the end of a line" do let(:polytex) do <<-'EOS' lorem ipsum dolor sit amet.%this is a comment EOS end it { should include("amet.") } end context "with a section and label" do let(:polytex) do <<-'EOS' % \section{Foo} % \label{sec:foo} EOS end it { should eq '' } end context "with a code listing" do let(:polytex) do <<-'EOS' % \begin{codelisting} % \heading{A hello program in Ruby.} % \label{code:hello} % %= lang:ruby % \begin{code} % def hello % "hello, world!" % end % \end{code} % \end{codelisting} EOS end it { should eq '' } end context "with a code inclusion" do let(:polytex) { '% %= << spec/spec_helper.rb' } it { should eq '' } end context "with a literal percent" do let(:polytex) { '87.3\% of statistics are made up' } it { should resemble '87.3% of statistics are made up' } end context "with characters before the percent" do let(:polytex) { 'foo % bar' } it { should resemble 'foo' } end context "with two percent signs" do let(:polytex) { 'foo % bar % baz' } it { should resemble 'foo' } end context "with display math" do let(:polytex) do <<-'EOS' % \[ % \begin{bmatrix} % 1 & \cdots & 0 \\ % \vdots & \ddots & \vdots \\ % 2 & \cdots & 0 % \end{bmatrix} % \] EOS end it { should eq '' } end context "with a percent-equals" do context "with an opening tag" do let(:polytex) { '%=
' } end end end describe "a complete document" do let(:polytex) do <<-'EOS' \documentclass{book} \begin{document} lorem ipsum \end{document} EOS end it { should resemble "lorem ipsum
" } end describe "a manual break" do let(:polytex) { 'foo \\\\ bar' } it { should include '' } end describe "paragraphs" do let(:polytex) { 'lorem ipsum' } it { should resemble "lorem ipsum
" } it { should_not resemble 'lorem ipsum
' } end describe "free span" do let(:polytex) do <<-'EOS' \chapter{Basics} % (fold) \label{cha:basics} %= EOS end it { should resemble('') } it { should_not resemble('') } end describe '\maketitle' do context "with all elements filled out explicitly" do let(:polytex) do <<-'EOS' \title{Foo \\ \emph{Bar}} \subtitle{\href{http://example.com/}{Baz}} \author{Michael Hartl} \date{January 1, 2013} \begin{document} \maketitle \end{document} EOS end it do should resemble <<-'EOS' EOS end it "should not have repeated title elements" do expect(processed_text.scan(/Michael Hartl/).length).to eq 1 end end context "with Unicode" do let(:polytex) do <<-'EOS' \title{A könyv címe} \subtitle{Alcím - itt lesz az alcím} \author{Árvíztűrő fúrógép} \date{January 1, 2013} \begin{document} \maketitle \end{document} EOS end it do should resemble <<-'EOS'
Lorem ipsum
dolor sit amet