Skip to content

Commit

Permalink
more consistent spacing of block-level elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ Ross committed Jul 1, 2011
1 parent d4353d9 commit 689f6cb
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 18 deletions.
2 changes: 2 additions & 0 deletions block.go
Expand Up @@ -942,6 +942,7 @@ func (parser *Parser) blockOliPrefix(data []byte) int {
// parse ordered or unordered list block
func (parser *Parser) blockList(out *bytes.Buffer, data []byte, flags int) int {
i := 0
flags |= LIST_ITEM_BEGINNING_OF_LIST
work := func() bool {
j := 0
for i < len(data) {
Expand All @@ -951,6 +952,7 @@ func (parser *Parser) blockList(out *bytes.Buffer, data []byte, flags int) int {
if j == 0 || flags&LIST_ITEM_END_OF_LIST != 0 {
break
}
flags &= ^LIST_ITEM_BEGINNING_OF_LIST
}
return true
}
Expand Down
22 changes: 11 additions & 11 deletions block_test.go
Expand Up @@ -86,10 +86,10 @@ func TestPrefixHeaderNoExtensions(t *testing.T) {
"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",

"* List\n# Header\n* List\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n<li><p>List</p></li>\n</ul>\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",

"* List\n#Header\n* List\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n<li><p>List</p></li>\n</ul>\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",

"* List\n * Nested list\n # Nested header\n",
"<ul>\n<li><p>List</p>\n\n<ul>\n<li><p>Nested list</p>\n\n" +
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestPrefixHeaderSpaceExtension(t *testing.T) {
"<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",

"* List\n# Header\n* List\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n<li><p>List</p></li>\n</ul>\n",
"<ul>\n<li><p>List</p>\n\n<h1>Header</h1></li>\n\n<li><p>List</p></li>\n</ul>\n",

"* List\n#Header\n* List\n",
"<ul>\n<li>List\n#Header</li>\n<li>List</li>\n</ul>\n",
Expand Down Expand Up @@ -285,10 +285,10 @@ func TestUnorderedList(t *testing.T) {
"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",

"* Yin\n\n* Yang\n",
"<ul>\n<li><p>Yin</p></li>\n<li><p>Yang</p></li>\n</ul>\n",
"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",

"* Ting\n\n* Bong\n* Goo\n",
"<ul>\n<li><p>Ting</p></li>\n<li><p>Bong</p></li>\n<li><p>Goo</p></li>\n</ul>\n",
"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",

"+ Hello\n",
"<ul>\n<li>Hello</li>\n</ul>\n",
Expand All @@ -300,10 +300,10 @@ func TestUnorderedList(t *testing.T) {
"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",

"+ Yin\n\n+ Yang\n",
"<ul>\n<li><p>Yin</p></li>\n<li><p>Yang</p></li>\n</ul>\n",
"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",

"+ Ting\n\n+ Bong\n+ Goo\n",
"<ul>\n<li><p>Ting</p></li>\n<li><p>Bong</p></li>\n<li><p>Goo</p></li>\n</ul>\n",
"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",

"- Hello\n",
"<ul>\n<li>Hello</li>\n</ul>\n",
Expand All @@ -315,10 +315,10 @@ func TestUnorderedList(t *testing.T) {
"<ul>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ul>\n",

"- Yin\n\n- Yang\n",
"<ul>\n<li><p>Yin</p></li>\n<li><p>Yang</p></li>\n</ul>\n",
"<ul>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ul>\n",

"- Ting\n\n- Bong\n- Goo\n",
"<ul>\n<li><p>Ting</p></li>\n<li><p>Bong</p></li>\n<li><p>Goo</p></li>\n</ul>\n",
"<ul>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ul>\n",

"*Hello\n",
"<p>*Hello</p>\n",
Expand Down Expand Up @@ -393,10 +393,10 @@ func TestOrderedList(t *testing.T) {
"<ol>\n<li>Ting</li>\n<li>Bong</li>\n<li>Goo</li>\n</ol>\n",

"1. Yin\n\n2. Yang\n",
"<ol>\n<li><p>Yin</p></li>\n<li><p>Yang</p></li>\n</ol>\n",
"<ol>\n<li><p>Yin</p></li>\n\n<li><p>Yang</p></li>\n</ol>\n",

"1. Ting\n\n2. Bong\n3. Goo\n",
"<ol>\n<li><p>Ting</p></li>\n<li><p>Bong</p></li>\n<li><p>Goo</p></li>\n</ol>\n",
"<ol>\n<li><p>Ting</p></li>\n\n<li><p>Bong</p></li>\n\n<li><p>Goo</p></li>\n</ol>\n",

"1 Hello\n",
"<p>1 Hello</p>\n",
Expand Down
12 changes: 8 additions & 4 deletions html.go
Expand Up @@ -252,9 +252,10 @@ func (options *Html) BlockCodeGithub(out *bytes.Buffer, text []byte, lang string


func (options *Html) BlockQuote(out *bytes.Buffer, text []byte) {
doubleSpace(out)
out.WriteString("<blockquote>\n")
out.Write(text)
out.WriteString("</blockquote>")
out.WriteString("</blockquote>\n")
}

func (options *Html) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) {
Expand All @@ -263,7 +264,7 @@ func (options *Html) Table(out *bytes.Buffer, header []byte, body []byte, column
out.Write(header)
out.WriteString("\n</thead>\n<tbody>\n")
out.Write(body)
out.WriteString("\n</tbody>\n</table>")
out.WriteString("\n</tbody>\n</table>\n")
}

func (options *Html) TableRow(out *bytes.Buffer, text []byte) {
Expand Down Expand Up @@ -295,9 +296,9 @@ func (options *Html) List(out *bytes.Buffer, text func() bool, flags int) {
doubleSpace(out)

if flags&LIST_TYPE_ORDERED != 0 {
out.WriteString("<ol>\n")
out.WriteString("<ol>")
} else {
out.WriteString("<ul>\n")
out.WriteString("<ul>")
}
if !text() {
out.Truncate(marker)
Expand All @@ -311,6 +312,9 @@ func (options *Html) List(out *bytes.Buffer, text func() bool, flags int) {
}

func (options *Html) ListItem(out *bytes.Buffer, text []byte, flags int) {
if flags&LIST_ITEM_CONTAINS_BLOCK != 0 || flags&LIST_ITEM_BEGINNING_OF_LIST != 0 {
doubleSpace(out)
}
out.WriteString("<li>")
out.Write(text)
out.WriteString("</li>\n")
Expand Down
1 change: 1 addition & 0 deletions markdown.go
Expand Up @@ -51,6 +51,7 @@ const (
const (
LIST_TYPE_ORDERED = 1 << iota
LIST_ITEM_CONTAINS_BLOCK
LIST_ITEM_BEGINNING_OF_LIST
LIST_ITEM_END_OF_LIST
)

Expand Down
2 changes: 2 additions & 0 deletions upskirtref/Auto links.html
Expand Up @@ -7,9 +7,11 @@
<li><a href="http://example.com/">http://example.com/</a></li>
<li>It should.</li>
</ul>

<blockquote>
<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
</blockquote>

<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>

<pre><code>or here: &lt;http://example.com/&gt;
Expand Down
2 changes: 1 addition & 1 deletion upskirtref/Blockquotes with code blocks.html
Expand Up @@ -12,4 +12,4 @@
return &quot;working&quot;;
}
</code></pre>
</blockquote>
</blockquote>
4 changes: 3 additions & 1 deletion upskirtref/Nested blockquotes.html
@@ -1,7 +1,9 @@
<blockquote>
<p>foo</p>

<blockquote>
<p>bar</p>
</blockquote>

<p>foo</p>
</blockquote>
</blockquote>
14 changes: 14 additions & 0 deletions upskirtref/Ordered and unordered lists.html
Expand Up @@ -12,7 +12,9 @@ <h2>Unordered</h2>

<ul>
<li><p>asterisk 1</p></li>

<li><p>asterisk 2</p></li>

<li><p>asterisk 3</p></li>
</ul>

Expand All @@ -30,7 +32,9 @@ <h2>Unordered</h2>

<ul>
<li><p>Plus 1</p></li>

<li><p>Plus 2</p></li>

<li><p>Plus 3</p></li>
</ul>

Expand All @@ -48,7 +52,9 @@ <h2>Unordered</h2>

<ul>
<li><p>Minus 1</p></li>

<li><p>Minus 2</p></li>

<li><p>Minus 3</p></li>
</ul>

Expand All @@ -74,15 +80,19 @@ <h2>Ordered</h2>

<ol>
<li><p>First</p></li>

<li><p>Second</p></li>

<li><p>Third</p></li>
</ol>

<p>and using spaces:</p>

<ol>
<li><p>One</p></li>

<li><p>Two</p></li>

<li><p>Three</p></li>
</ol>

Expand All @@ -93,7 +103,9 @@ <h2>Ordered</h2>

<p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
back.</p></li>

<li><p>Item 2.</p></li>

<li><p>Item 3.</p></li>
</ol>

Expand Down Expand Up @@ -129,13 +141,15 @@ <h2>Nested</h2>

<ol>
<li><p>First</p></li>

<li><p>Second:</p>

<ul>
<li>Fee</li>
<li>Fie</li>
<li>Foe</li>
</ul></li>

<li><p>Third</p></li>
</ol>

Expand Down
1 change: 1 addition & 0 deletions upskirtref/Tabs.html
@@ -1,6 +1,7 @@
<ul>
<li><p>this is a list item
indented with tabs</p></li>

<li><p>this is a list item
indented with spaces</p></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion upskirtref/Tidyness.html
Expand Up @@ -6,4 +6,4 @@
<li>asterisk 2</li>
<li>asterisk 3</li>
</ul>
</blockquote>
</blockquote>

0 comments on commit 689f6cb

Please sign in to comment.