From 00cb90e934e2e64ea2c45d77f41d05970c1427d0 Mon Sep 17 00:00:00 2001 From: Russ Ross Date: Mon, 27 Jun 2011 16:06:32 -0600 Subject: [PATCH] horizontal rule and list testing --- block.go | 7 ++- block_test.go | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 3 deletions(-) diff --git a/block.go b/block.go index 8b2bfa0..669205a 100644 --- a/block.go +++ b/block.go @@ -922,7 +922,7 @@ func blockListItem(out *bytes.Buffer, rndr *render, data []byte, flags *int) int } // skip leading whitespace on first line - for beg < len(data) && data[beg] == ' ' { + for beg < len(data) && (data[beg] == ' ' || data[beg] == '\t') { beg++ } @@ -965,7 +965,7 @@ func blockListItem(out *bytes.Buffer, rndr *render, data []byte, flags *int) int pre = i if data[beg] == '\t' { i = 1 - pre = 8 + pre = TAB_SIZE } chunk := data[beg+i : end] @@ -976,7 +976,8 @@ func blockListItem(out *bytes.Buffer, rndr *render, data []byte, flags *int) int contains_block = true } - if pre == orgpre { // the following item must have the same indentation + // the following item must have the same indentation + if pre == orgpre { break } diff --git a/block_test.go b/block_test.go index 602879b..ef078a8 100644 --- a/block_test.go +++ b/block_test.go @@ -204,3 +204,167 @@ func TestUnderlineHeaders(t *testing.T) { } doTestsBlock(t, tests, 0) } + +func TestHorizontalRule(t *testing.T) { + var tests = []string{ + "-\n", + "

-

\n", + + "--\n", + "

--

\n", + + "---\n", + "
\n", + + "----\n", + "
\n", + + "*\n", + "

*

\n", + + "**\n", + "

**

\n", + + "***\n", + "
\n", + + "****\n", + "
\n", + + "_\n", + "

_

\n", + + "__\n", + "

__

\n", + + "___\n", + "
\n", + + "____\n", + "
\n", + + "-*-\n", + "

-*-

\n", + + "- - -\n", + "
\n", + + "* * *\n", + "
\n", + + "_ _ _\n", + "
\n", + + "-----*\n", + "

-----*

\n", + + " ------ \n", + "
\n", + + "Hello\n***\n", + "

Hello

\n\n
\n", + + "---\n***\n___\n", + "
\n\n
\n\n
\n", + } + doTestsBlock(t, tests, 0) +} + +func TestUnorderedList(t *testing.T) { + var tests = []string{ + "* Hello\n", + "\n", + + "* Yin\n* Yang\n", + "\n", + + "* Ting\n* Bong\n* Goo\n", + "\n", + + "* Yin\n\n* Yang\n", + "\n", + + "* Ting\n\n* Bong\n* Goo\n", + "\n", + + "+ Hello\n", + "\n", + + "+ Yin\n+ Yang\n", + "\n", + + "+ Ting\n+ Bong\n+ Goo\n", + "\n", + + "+ Yin\n\n+ Yang\n", + "\n", + + "+ Ting\n\n+ Bong\n+ Goo\n", + "\n", + + "- Hello\n", + "\n", + + "- Yin\n- Yang\n", + "\n", + + "- Ting\n- Bong\n- Goo\n", + "\n", + + "- Yin\n\n- Yang\n", + "\n", + + "- Ting\n\n- Bong\n- Goo\n", + "\n", + + "*Hello\n", + "

*Hello

\n", + + "* Hello \n", + "\n", + + "* Hello \n Next line \n", + "\n", + + "Paragraph\n* No linebreak\n", + "

Paragraph\n* No linebreak

\n", + + "Paragraph\n\n* Linebreak\n", + "

Paragraph

\n\n\n", + + "* List\n * Nested list\n", + "\n", + + "* List\n\n * Nested list\n", + "\n", + + "* List\n Second line\n\n + Nested\n", + "\n", + + "* List\n + Nested\n\n Continued\n", + "\n", + + "* List\n * shallow indent\n", + "\n", + + "* List\n" + + " * shallow indent\n" + + " * part of second list\n" + + " * still second\n" + + " * almost there\n" + + " * third level\n", + "\n", + } + doTestsBlock(t, tests, 0) +}