Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more consistent spacing of block-level elements

  • Loading branch information...
commit 689f6cb79b7436f387720213cb6a9810649762b6 1 parent d4353d9
Russ Ross authored
View
2  block.go
@@ -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) {
@@ -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
}
View
22 block_test.go
@@ -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" +
@@ -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",
@@ -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",
@@ -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",
@@ -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",
@@ -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",
View
12 html.go
@@ -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) {
@@ -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) {
@@ -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)
@@ -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")
View
1  markdown.go
@@ -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
)
View
2  upskirtref/Auto links.html
@@ -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;
View
2  upskirtref/Blockquotes with code blocks.html
@@ -12,4 +12,4 @@
return &quot;working&quot;;
}
</code></pre>
-</blockquote>
+</blockquote>
View
4 upskirtref/Nested blockquotes.html
@@ -1,7 +1,9 @@
<blockquote>
<p>foo</p>
+
<blockquote>
<p>bar</p>
</blockquote>
+
<p>foo</p>
-</blockquote>
+</blockquote>
View
14 upskirtref/Ordered and unordered lists.html
@@ -12,7 +12,9 @@
<ul>
<li><p>asterisk 1</p></li>
+
<li><p>asterisk 2</p></li>
+
<li><p>asterisk 3</p></li>
</ul>
@@ -30,7 +32,9 @@
<ul>
<li><p>Plus 1</p></li>
+
<li><p>Plus 2</p></li>
+
<li><p>Plus 3</p></li>
</ul>
@@ -48,7 +52,9 @@
<ul>
<li><p>Minus 1</p></li>
+
<li><p>Minus 2</p></li>
+
<li><p>Minus 3</p></li>
</ul>
@@ -74,7 +80,9 @@
<ol>
<li><p>First</p></li>
+
<li><p>Second</p></li>
+
<li><p>Third</p></li>
</ol>
@@ -82,7 +90,9 @@
<ol>
<li><p>One</p></li>
+
<li><p>Two</p></li>
+
<li><p>Three</p></li>
</ol>
@@ -93,7 +103,9 @@
<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>
@@ -129,6 +141,7 @@
<ol>
<li><p>First</p></li>
+
<li><p>Second:</p>
<ul>
@@ -136,6 +149,7 @@
<li>Fie</li>
<li>Foe</li>
</ul></li>
+
<li><p>Third</p></li>
</ol>
View
1  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>
View
2  upskirtref/Tidyness.html
@@ -6,4 +6,4 @@
<li>asterisk 2</li>
<li>asterisk 3</li>
</ul>
-</blockquote>
+</blockquote>
Please sign in to comment.
Something went wrong with that request. Please try again.