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 [/y] \n [n] no [/n] \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 context 'two matches after each other' do let(:source) { "$yes-no\n [y] **yes** [/y] \n $end $yes-no\ [n] **no** [/n] \n $end" } let(:expected) do "" end it 'pre-processes correctly' do expect(subject.to_html.gsub("\n", '')).to eq(expected) end end context 'two callouts after each other' do let(:source) { "$~callout\n ##yes ~$ $~callout\n ##yes ~$" } let(:expected) do "
\n

yes

\n\n
\n
\n

yes

\n\n
\n" end it 'pre-processes correctly' do expect(subject.to_html).to eq(expected) end end context 'ticks inside table' do let(:source) { "|table|header|\n|$yes-no [y] yes [/y] $end|here|" } let(:expected) do "\n \n \n \n \n \n \n \n \n \n \n
tableheader
  • yes
here
\n" end it 'pre-processes correctly' do expect(subject.to_html).to eq(expected) end end end