spec/kramdown/converter/man_spec.rb in kramdown-man-0.1.3 vs spec/kramdown/converter/man_spec.rb in kramdown-man-0.1.4
- old
+ new
@@ -75,10 +75,26 @@
let(:text) { doc.root.children[0].children[0] }
it "should convert text elements" do
subject.convert_text(text).should == content
end
+
+ context "when the text has two-space indentation" do
+ let(:content) { "Foo\n bar\n baz" }
+
+ it "should strip leading whitespace from each line" do
+ subject.convert_text(text).should == content.gsub("\n ","\n")
+ end
+ end
+
+ context "when the text has tab indentation" do
+ let(:content) { "Foo\n\tbar\n\tbaz" }
+
+ it "should strip leading whitespace from each line" do
+ subject.convert_text(text).should == content.gsub("\n\t","\n")
+ end
+ end
end
describe "#convert_typographic_sym" do
context "ndash" do
let(:doc) { Kramdown::Document.new("-- foo") }
@@ -366,26 +382,82 @@
it "should convert p elements into '.PP\\ntext'" do
subject.convert_p(p).should == ".PP\n#{text}"
end
- context "when the second line is indented with two spaces" do
+ context "when the paragraph starts with a codespan element" do
let(:option) { '--foo' }
let(:text) { 'Foo bar baz' }
- let(:doc) { Kramdown::Document.new("`#{option}`\n #{text}") }
+ let(:doc) { Kramdown::Document.new("`#{option}`\n\t#{text}") }
it "should convert p elements into '.TP\\n\\fB\\fC--option\\fR\\ntext...'" do
subject.convert_p(p).should == ".TP\n\\fB\\fC#{option}\\fR\n#{text}"
end
+
+ context "when there is only one codespan element" do
+ let(:code) { 'code' }
+ let(:doc) { Kramdown::Document.new("`#{code}`") }
+
+ it "should convert p elements into '.PP\\n\\fB\\fC...\\fR'" do
+ subject.convert_p(p).should == ".PP\n\\fB\\fC#{code}\\fR"
+ end
+ end
+
+ context "when there are more than one codespan element" do
+ let(:flag) { '-f' }
+ let(:option) { '--foo' }
+ let(:text) { 'Foo bar baz' }
+ let(:doc) { Kramdown::Document.new("`#{flag}`, `#{option}`\n\t#{text}") }
+
+ it "should convert p elements into '.TP\\n\\fB\\fC-o\\fR, \\fB\\fC--option\\fR\\ntext...'" do
+ subject.convert_p(p).should == ".TP\n\\fB\\fC#{flag}\\fR, \\fB\\fC#{option}\\fR\n#{text}"
+ end
+
+ context "when there is no newline" do
+ let(:doc) { Kramdown::Document.new("`#{flag}` `#{option}`") }
+
+ it "should convert the p element into a '.HP\\n...'" do
+ subject.convert_p(p).should == ".HP\n\\fB\\fC#{flag}\\fR \\fB\\fC#{option}\\fR"
+ end
+ end
+ end
end
- context "when the second line is indented with a tab" do
+ context "when the paragraph starts with a em element" do
let(:option) { '--foo' }
let(:text) { 'Foo bar baz' }
- let(:doc) { Kramdown::Document.new("`#{option}`\n\t#{text}") }
+ let(:doc) { Kramdown::Document.new("*#{option}*\n\t#{text}") }
it "should convert p elements into '.TP\\n\\fB\\fC--option\\fR\\ntext...'" do
- subject.convert_p(p).should == ".TP\n\\fB\\fC#{option}\\fR\n#{text}"
+ subject.convert_p(p).should == ".TP\n\\fI#{option}\\fP\n#{text}"
+ end
+
+ context "when there is only one em element" do
+ let(:text) { 'foo' }
+ let(:doc) { Kramdown::Document.new("*#{text}*") }
+
+ it "should convert p elements into '.PP\\n\\fB\\fC...\\fR'" do
+ subject.convert_p(p).should == ".PP\n\\fI#{text}\\fP"
+ end
+ end
+
+ context "when there are more than one em element" do
+ let(:flag) { '-f' }
+ let(:option) { '--foo' }
+ let(:text) { 'Foo bar baz' }
+ let(:doc) { Kramdown::Document.new("*#{flag}*, *#{option}*\n\t#{text}") }
+
+ it "should convert p elements into '.TP\\n\\fI-o\\fP, \\fI--option\\fP\\ntext...'" do
+ subject.convert_p(p).should == ".TP\n\\fI\\#{flag}\\fP, \\fI#{option}\\fP\n#{text}"
+ end
+
+ context "when there is no newline" do
+ let(:doc) { Kramdown::Document.new("*#{flag}* *#{option}*") }
+
+ it "should convert the p element into a '.HP\\n...'" do
+ subject.convert_p(p).should == ".HP\n\\fI\\#{flag}\\fP \\fI#{option}\\fP"
+ end
+ end
end
end
end
describe "#convert_em" do