# 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'
foo \includegraphics{foo.png} bar
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'
EOS
end
end
context "with a Unicode filename" do
let(:polytex) { '\includegraphics{images/grusväg.jpg}' }
it { should include 'images/grusväg.jpg' }
end
end
describe "figures" do
let(:polytex) do <<-'EOS'
\begin{figure}
lorem
\end{figure}
EOS
end
it do
should resemble <<-'EOS'
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'
EOS
end
end
context "with a label and a cross-reference and a quote" do
let(:polytex) do <<-'EOS'
\begin{figure}
\begin{quote}
lorem
\end{quote}
\label{fig:foo}
\end{figure}
Figure~\ref{fig:foo} or Fig.~\ref{fig:foo}
EOS
end
it do
should resemble <<-'EOS'
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'
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'
EOS
end
end
context "with a caption containing only a label" do
let(:polytex) do <<-'EOS'
\chapter{The chapter}
\begin{figure}
\includegraphics{foo.png}
\caption{\label{fig:foo}}
\end{figure}
EOS
end
it { should include 'Figure 1.1' }
it { should_not include 'Figure 1.1:' }
end
context "with labels and cross-references" 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'
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'
EOS
end
context "using the \\image command and a PDF file image file" do
let(:polytex) do <<-'EOS'
\chapter{The chapter}
\label{cha:lorem_ipsum}
\begin{figure}
\image{foo_bar.pdf}
\caption{This is a caption.\label{fig:foo}}
\end{figure}
EOS
end
it do
should resemble <<-'EOS'
EOS
end
end
context "using the \\imagebox command and PDF image file" do
let(:polytex) do <<-'EOS'
\chapter{The chapter}
\label{cha:lorem_ipsum}
\begin{figure}
\imagebox{foo_bar.pdf}
\caption{This is a caption.\label{fig:foo}}
\end{figure}
EOS
end
it do
should resemble <<-'EOS'
EOS
end
end
end
end
end
end