require 'spec_helper' module Hemingway describe Parser do before do @parser = Parser.new end describe "#tag" do it 'should parse an emph tag' do html = @parser.parse("a \\emph{hey} b").html html.should == "

a hey b

" end it 'should parse a texttt tag' do html = @parser.parse("\\texttt{hey}").html html.should == "

hey

" end it 'should parse a textbf tag' do html = @parser.parse("\\textbf{hey}").html html.should == "

hey

" end it 'should parse a textsc tag' do html = @parser.parse("\\textsc{hey}").html html.should == "

hey

" end it 'should allow sequences of content within a tag' do html = @parser.parse("\\textsc{hey \\emph{vibes} \& times}").html html.should == "

hey vibes & times

" end end describe "#nesting" do it 'should allow me to nest tags' do html = @parser.parse("\\emph{\\texttt{hey}}").html html.should == "

hey

" end it 'should REALLY allow me to next tags' do html = @parser.parse("\\emph{\\texttt{\\texttt{hey}}}").html html.should == "

hey

" end it 'should escape special characters in a tag' do html = @parser.parse("\\emph{War \\& Peace}").html html.should == "

War & Peace

" end end describe "#vspace" do it 'should build vertical space taking divs' do html = @parser.parse("\\vspace{5mm}").html html.should == "

" end it 'should build vertical space taking divs with double digit heights' do html = @parser.parse("\\vspace{12mm}").html html.should == "

" end end describe '#hfill' do it 'supports right justifying on a line' do html = @parser.parse("The love, \\hfill Will").html html.should == "

The love, Will

" end it 'allows me to put all the good shit in' do html = @parser.parse("The love, \\hfill \\emph{Will} \\textsc{Tha Thrill} $\\delta$ \\textbf{Myers}").html html.should == "

The love, Will Tha Thrill δ Myers

" end end describe '#neatline' do it 'allows me to add fancy
s to a page' do html = @parser.parse("\\neatline").html html.should == "


" end end describe "#accents" do it 'allows me to put accents inline with text' do html = @parser.parse("Charm\\'{e}e de vous voir. Je suis tr\\`{e} contente de vous voir.").html html.should == "

Charmée de vous voir. Je suis trè contente de vous voir.

" end end end end