M spec/gmi_renderer_spec.cr => spec/gmi_renderer_spec.cr +53 -1
@@ 156,7 156,7 @@ there hello"
actual.should eq(expected)
end
- it "should render ordered lists as unrodered" do
+ it "should render ordered lists as unordered" do
input = "1. First element
2. Second element
3. Third element"
@@ 168,4 168,56 @@ there hello"
actual.should eq(expected)
end
+
+ it "should render blockquotes" do
+ input = "> hello
+> world"
+ expected = "> hello
+> world"
+
+ actual = render_to_gmi(input)
+
+ actual.should eq(expected)
+ end
+
+ it "should render blockquotes with formatted text inside" do
+ input = "> hello *world* **strong** [link](http://example.com/)
+> world `pre`  and other stuff"
+ expected = "> hello *world* **strong** link[1]
+> world `pre`
+=> https://octodex.github.com/images/yaktocat.png Image of Yaktocat
+> and other stuff
+
+## Links
+
+=> http://example.com/ 1"
+
+ actual = render_to_gmi(input)
+
+ actual.should eq(expected)
+ end
+
+ it "should render blockquotes with formatted text inside with normal content around it" do
+ input = "this is normal *content* all right
+> hello *world* **strong** [link](http://example.com/)
+> world `pre`  and other stuff
+this is quote too
+
+but this is not"
+ expected = "this is normal *content* all right
+> hello *world* **strong** link[1]
+> world `pre`
+=> https://octodex.github.com/images/yaktocat.png Image of Yaktocat
+> and other stuff
+> this is quote too
+but this is not
+
+## Links
+
+=> http://example.com/ 1"
+
+ actual = render_to_gmi(input)
+
+ actual.should eq(expected)
+ end
end
M src/gmi_renderer.cr => src/gmi_renderer.cr +4 -1
@@ 13,6 13,7 @@ class GmiRenderer < Markd::Renderer
@output_io = String::Builder.new
@last_output = "\n"
@is_newline = false
+ @is_blockquote = false
end
def heading(node, entering)
@@ 38,7 39,7 @@ class GmiRenderer < Markd::Renderer
end
def block_quote(node, entering)
- raise "Not implemented"
+ @is_blockquote = entering
end
def thematic_break(node, entering)
@@ 109,6 110,8 @@ class GmiRenderer < Markd::Renderer
def text(node, entering)
actual_text = node.text
actual_text = node.text.lstrip if @is_newline
+ @output_io << "> " if (@is_blockquote && @is_newline)
+
@is_newline = false
@output_io << actual_text