# 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'

Chapter 1 Foo bar

1.1 Foobar

Lorem ipsum.1

  1. Cicero

Chapter 2 Bar

Dolor sit amet.

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'

Chapter 1 Foo bar

1.1 Foobar

Lorem ipsum.1

  1. Cicero

Chapter 2 Bar

Dolor sit amet.1

Hey Jude.2

  1. Still Cicero
  2. Lennon/McCartney
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 '1' } 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'

Chapter 1 Foo bar

1.1 Foobar

Lorem ipsum.*

Chapter 2 Bar

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 describe "footnote inside a section*" do let(:polytex) do <<-'EOS' \chapter{The first} Test \chapter{The second} Also test \chapter{Lorem} Foo bar \section*{Baz} Lorem ipsum.\footnote{Dolor sit amet.} EOS end it { should include 'cha-3_footnote' } end end