# encoding=utf-8 require 'spec_helper' describe 'Polytexnic::Pipeline#to_html' do let(:pipeline) { Polytexnic::Pipeline.new(polytex) } subject(:processed_text) { pipeline.to_html } describe '\chapter' do context "with a name" do let(:polytex) do <<-'EOS' \chapter{Foo \emph{bar}} \label{cha:foo} EOS end let(:output) do <<-'EOS'

Chapter 1 Foo bar

EOS end it { should resemble output } end context "with no name" do let(:polytex) do <<-'EOS' \chapter{} \label{cha:foo} EOS end let(:output) do <<-'EOS'

Chapter 1

EOS end it { should resemble output } end context "with an alternate to 'Chapter'" do let(:language_labels) do { "chapter" => {"word" => "fejezet", "order" => "reverse"} } end let(:pipeline) do Polytexnic::Pipeline.new(polytex, language_labels: language_labels) end let(:polytex) do <<-'EOS' \chapter{Foo \emph{bar}} \label{cha:foo} EOS end let(:output) do <<-'EOS'

1 fejezet Foo bar

EOS end it { should resemble output } context "chapter, etc., linking" do let(:language_labels) do { "chapter" => {"word" => "Capítulo", "order" => "standard"}, "section" => "Sección", "table" => "Tabla", "aside" => "Caja", "figure" => "Figura", "fig" => "Fig", "listing" => "Listado", "equation" => "Ecuación", "eq" => "Ec", } end let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo} Capítulo~\ref{cha:foo} Sección~\ref{sec:bar} Tabla~\ref{table:bar} Caja~\ref{aside:bar} Figura~\ref{fig:bar} Fig.~\ref{fig:bar} Listado~\ref{code:bar} Ecuación~\ref{eq:bar} Ec.~\ref{eq:bar} EOS end let(:capitulo) { 'Capítulo' } let(:seccion) { 'Sección' } let(:ecuacion) { 'Ecuación' } it { should include %(class="hyperref">#{capitulo}) } it { should include %(class="hyperref">#{seccion}) } it { should include %(class="hyperref">Tabla) } it { should include %(class="hyperref">Figura) } it { should include %(class="hyperref">Fig.) } it { should include %(class="hyperref">Caja) } it { should include %(class="hyperref">Listado) } it { should include %(class="hyperref">#{ecuacion}) } it { should include %(class="hyperref">Ec.) } end end end describe '\section' do let(:polytex) do <<-'EOS' Lorem ipsum \section{Foo} \label{sec:foo} EOS end let(:output) do <<-'EOS'

Lorem ipsum

1 Foo

EOS end it { should resemble output } end describe '\subsection' do let(:polytex) do <<-'EOS' \section{Foo} \label{sec:foo} \subsection{Bar} \label{sec:bar} EOS end let(:output) do <<-'EOS'

1 Foo

1.1 Bar

EOS end it { should resemble output } end describe '\subsubsection' do let(:polytex) do <<-'EOS' \chapter{The Chapter} \label{cha:the_chapter} \section{Foo} \label{sec:foo} \subsection{Bar} \label{sec:bar} \subsubsection{Baz} \label{sec:baz} EOS end let(:output) do <<-'EOS'

Chapter 1 The Chapter

1.1 Foo

1.1.1 Bar

EOS end it { should resemble output } end describe '\chapter*' do let(:polytex) do <<-'EOS' \chapter*{A preface} Lorem ipsum EOS end it { should resemble '
' } end describe '\section*, etc.' do let(:polytex) do <<-'EOS' \section*{Foo: baz} \subsection*{Bar} Lorem ipsum \section{Baz} EOS end let(:output) do <<-'EOS'

Foo: baz

Bar

Lorem ipsum

1 Baz

EOS end it { should resemble output } end describe 'chapter cross-references' do let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo_bar} Chapter~\ref{cha:foo_bar} and Chapter \ref{cha:foo_baz} \chapter{Baz} \label{cha:foo_baz} Chapter~\ref{cha:foo_baz} and Chapter \ref{cha:foo_bar} EOS end it do should resemble <<-'EOS'

Chapter 1 Foo

Chapter 1 and Chapter 2

Chapter 2 Baz

Chapter 2 and Chapter 1

EOS end end describe "section cross-references" do let(:polytex) do <<-'EOS' \section{Foo} \label{sec:foo} Section~\ref{sec:bar} and Section~\ref{sec:baz} \subsection{Bar} \label{sec:bar} Section~\ref{sec:foo} \subsubsection{Baz} \label{sec:baz} EOS end it do should resemble <<-'EOS'

1 Foo

Section 1.1 and Section 1.1.1

EOS end end describe 'missing cross-references' do let(:polytex) do <<-'EOS' \chapter{Foo} \label{cha:foo} Chapter~\ref{cha:bar} EOS end it do should resemble <<-'EOS'

Chapter 1 Foo

Chapter cha:bar

EOS end end describe "frontmatter and mainmatter" do let(:polytex) do <<-'EOS' \frontmatter \chapter{Foo} Lorem ipsum.\footnote{Foo bar.} \mainmatter \chapter{Bar} \label{cha:bar} Chapter~\ref{cha:bar} EOS end it do should resemble <<-'EOS'

Foo

Lorem ipsum.1

  1. Foo bar. 

Chapter 1 Bar

Chapter 1

EOS end end end