# encoding=utf-8
require 'spec_helper'
describe 'Polytexnic::Pipeline#to_html' do
subject(:processed_text) { Polytexnic::Pipeline.new(polytex).to_html }
describe "first chapter with footnotes" do
let(:polytex) do <<-'EOS'
\chapter{Foo \emph{bar}}
\label{cha:foo}
\section{Foobar}
\label{sec:foobar}
Lorem ipsum.\footnote{Cicero}
\chapter{Bar}
\label{cha:bar}
Dolor sit amet.
EOS
end
let(:output) do <<-'EOS'
EOS
end
it { should resemble output }
it "should display the footnotes only once" do
expect(processed_text.scan(/id="cha-1_footnotes"/).length).to eq 1
end
end
describe "multiple chapters with footnotes" do
let(:polytex) do <<-'EOS'
\chapter{Foo \emph{bar}}
\label{cha:foo}
\section{Foobar}
\label{sec:foobar}
Lorem ipsum.\footnote{Cicero}
\chapter{Bar}
\label{cha:bar}
Dolor sit amet.\footnote{\emph{Still} Cicero}
Hey Jude.\footnote{Lennon/McCartney}
EOS
end
let(:output) do <<-'EOS'
Dolor sit amet.
Hey Jude.
EOS
end
it { should resemble output }
end
describe "in a chapter title" do
let(:polytex) { '\chapter{A chapter\protect\footnote{A footnote}}' }
it { should include '' }
end
describe "symbols in place of numbers" do
let(:polytex) do <<-'EOS'
\documentclass{book}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
\chapter{Foo \emph{bar}}
\label{cha:foo}
\section{Foobar}
\label{sec:foobar}
Lorem ipsum.\footnote{Cicero}
\chapter{Bar}
\label{cha:bar}
Dolor sit amet.\footnote{\emph{Still} Cicero}
Hey Jude!\footnote{Lennon/McCartney} Be afraid.
\end{document}
EOS
end
let(:output) do <<-'EOS'
Dolor sit amet.
Hey Jude!
Be afraid.
EOS
end
it { should resemble output }
end
describe "emphasis inside footnote with a period" do
let(:polytex) do <<-'EOS'
\chapter{Lorem}
Lorem ipsum\footnote{Dolor \emph{sit.}} amet. Consectetur.
EOS
end
it { should_not include ' amet' }
end
end