require 'spec_helper' describe Mastalk::Document do context 'Without mastalk syntax' do let(:context) { "###test\nwith markdown" } let(:expected) { "

test

\n

with markdown

\n" } subject { Mastalk::Document.new(context) } it 'kramdown behaviour with no tags' do expect(Mastalk::Document.new('test').to_html).to eq("

test

\n") end it 'converts to html' do expect(subject.to_html).to eq(expected) end context 'multiline' do let(:expected) { "

TEST

\n\n

with other stuff

\n\n" } let(:context) { "### TEST\r\n\r\nwith other stuff\r\n\r\n " } it 'converts to html' do expect(subject.to_html).to eq(expected) end end end subject { Mastalk::Document.new(source) } let(:expected) { "
test
\n" } context 'custom extension' do let(:source) { '$Etest$E' } it 'pre-processes custom tags' do subject.extension('$E') { |body| "
#{body}
" } expect(subject.to_html).to eq(expected) end context 'multi line' do let(:source) { '$Etest$E$Shello$FIN' } let(:expected) { "
test
\n
hello
\n" } it 'processes multi line' do subject.extension('$E') { |body| "
#{body}
" } subject.extension('$S', '$FIN') { |body| "
#{body}
" } expect(subject.to_html).to eq(expected) end end end context 'extension with start and stop' do let(:source) { '$STARTtest$END' } it 'pre-processes custom tags' do subject.extension('$START', '$END') { |body| "
#{body}
" } expect(subject.to_html).to eq(expected) end end context 'extension with other extensions inside' do let(:source) { "$why\n###header\nbody\n$why" } let(:expected) { "
\n

header

\n

body

\n\n
\n" } it 'parses nested structures' do expect(subject.to_html).to eq(expected) end end context 'with newline as end' do let(:source) { "$yes-no\n [y] yes \n [n] no \n $end $why\n###header\nbody\n$why" } let(:expected) do "\n

header

\n

body

\n\n
\n" end it 'pre-processes custom tags' do expect(subject.to_html).to eq(expected) end end end