~michalr/blog2gmi

69855be4fc38ae52c5927c99579f19c3d4310956 — MichaƂ Rudowicz 4 years ago 0aec2f9
Lists support
2 files changed, 45 insertions(+), 2 deletions(-)

M spec/gmi_renderer_spec.cr
M src/gmi_renderer.cr
M spec/gmi_renderer_spec.cr => spec/gmi_renderer_spec.cr +43 -0
@@ 106,4 106,47 @@ It does print hello world."

    actual.should eq(expected)
  end

  it "should render unordered lists" do
    input = "* First element
* Second element
* Third element"
    expected = "* First element
* Second element
* Third element"

    actual = render_to_gmi(input)

    actual.should eq(expected)
  end

  it "should render unordered lists when it is surrounded by other text" do
    input = "hello there
* First element
* Second element
* Third element
there hello"
    expected = "hello there
* First element
* Second element
* Third element
there hello"

    actual = render_to_gmi(input)

    actual.should eq(expected)
  end

  it "should render ordered lists as unrodered" do
    input = "1. First element
2. Second element
3. Third element"
    expected = "* First element
* Second element
* Third element"

    actual = render_to_gmi(input)

    actual.should eq(expected)
  end
end

M src/gmi_renderer.cr => src/gmi_renderer.cr +2 -2
@@ 30,11 30,11 @@ class GmiRenderer < Markd::Renderer
  end

  def list(node, entering)
    raise "Not implemented"
    add_newline_if_needed
  end

  def item(node, entering)
    raise "Not implemented"
    @output_io << "* " if entering
  end

  def block_quote(node, entering)