# encoding=utf-8 require 'spec_helper' describe 'Polytexnic::Pipeline#to_html' do subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html } describe "graphics" do let(:polytex) do <<-'EOS' \includegraphics{foo.png} EOS end it do should resemble <<-'EOS'
foo
EOS end it { should_not resemble 'class="figure"' } it { should_not resemble 'Figure' } context "with a PDF image" do let(:polytex) do <<-'EOS' \includegraphics{foo.pdf} EOS end it do should resemble <<-'EOS'
foo
EOS end end end describe "figures" do let(:polytex) do <<-'EOS' \begin{figure} lorem \end{figure} EOS end it do should resemble <<-'EOS'

lorem

Figure 1
EOS end context "with an explicit center environment" do let(:polytex) do <<-'EOS' \begin{figure} \begin{center} lorem \end{center} \end{figure} EOS end it do should resemble <<-'EOS'

lorem

Figure 1
EOS end end context "with a label and a cross-reference" do let(:polytex) do <<-'EOS' \begin{figure} lorem \label{fig:foo} \end{figure} Figure~\ref{fig:foo} or Fig.~\ref{fig:foo} EOS end it do should resemble <<-'EOS'

lorem

Figure 1

Figure 1 or Fig. 1

EOS end end context "with included graphics" do let(:polytex) do <<-'EOS' \begin{figure} \includegraphics{images/foo.png} \label{fig:foo} \end{figure} EOS end it do should resemble <<-'EOS'
foo
Figure 1
EOS end end context "with a caption" do let(:polytex) do <<-'EOS' \chapter{The chapter} \begin{figure} \includegraphics{foo.png} \caption{This is a \emph{caption} with $x$.} \end{figure} \begin{figure} \includegraphics{bar.png} \caption{This is another caption.} \end{figure} EOS end it do should resemble <<-'EOS'

Chapter 1 The chapter

foo
Figure 1.1: This is a caption with \( x \).
bar
Figure 1.2: This is another caption.
EOS end end context "with labels and cross-reference" do let(:polytex) do <<-'EOS' \chapter{The chapter} \label{cha:lorem_ipsum} \begin{figure} \includegraphics{foo.png} \caption{This is a caption.\label{fig:foo}} \end{figure} \begin{figure} \includegraphics{bar.png} \caption{This is another caption.\label{fig:bar}} \end{figure} Figure~\ref{fig:baz} \chapter{A second chapter} \label{cha:two} \begin{figure} \includegraphics{baz.png} \caption{Yet another.\label{fig:baz}} \end{figure} Figure~\ref{fig:foo} and Figure~\ref{fig:bar} EOS end it do should resemble <<-'EOS'

Chapter 1 The chapter

foo
Figure 1.1: This is a caption.
bar
Figure 1.2: This is another caption.

Figure 2.1

Chapter 2 A second chapter

baz
Figure 2.1: Yet another.

Figure 1.1 and Figure 1.2

EOS end context "with a centered image" do let(:polytex) do <<-'EOS' \chapter{The chapter} \label{cha:lorem_ipsum} \begin{figure} \centering \includegraphics{foo.png} \caption{This is a caption.\label{fig:foo}} \end{figure} EOS end it do should resemble <<-'EOS'

Chapter 1 The chapter

foo
Figure 1.1: This is a caption.
EOS end context "using the \\image command" do let(:polytex) do <<-'EOS' \chapter{The chapter} \label{cha:lorem_ipsum} \begin{figure} \image{foo_bar.png} \caption{This is a caption.\label{fig:foo}} \end{figure} EOS end it do should resemble <<-'EOS'

Chapter 1 The chapter

foo_bar
Figure 1.1: This is a caption.
EOS end end context "using the \\imagebox command" do let(:polytex) do <<-'EOS' \chapter{The chapter} \label{cha:lorem_ipsum} \begin{figure} \imagebox{foo_bar.png} \caption{This is a caption.\label{fig:foo}} \end{figure} EOS end it do should resemble <<-'EOS'

Chapter 1 The chapter

foo_bar
Figure 1.1: This is a caption.
EOS end end end end end end