~samwhited/blogsync

0cf27a46e2ee79b632d2afb47081112cdc2937dc — Sam Whited 1 year, 9 months ago 993c28c
blogsync: render lists and blockquotes correctly

Previously the space around them wasn't enough for write.as' markdown
parser, which has odd rules that don't comply with Common Mark or the
original markdown spec.
1 files changed, 12 insertions(+), 2 deletions(-)

M markdown.go
M markdown.go => markdown.go +12 -2
@@ 98,10 98,16 @@ func (*unwrapRenderer) renderImage(w io.Writer, node *blackfriday.Node, entering
func (rend *unwrapRenderer) renderList(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
	if entering {
		rend.listLevel++
		if rend.listLevel == 1 {
			io.WriteString(w, "\n")
		}
		return blackfriday.GoToNext
	}

	rend.listLevel--
	if rend.listLevel == 0 {
		io.WriteString(w, "\n")
	}
	return blackfriday.GoToNext
}



@@ 134,9 140,10 @@ func (*unwrapRenderer) renderHeading(w io.Writer, node *blackfriday.Node, enteri
}

func (rend *unwrapRenderer) renderBlockQuote(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
	io.WriteString(w, "\n")
	if !entering {
		io.WriteString(w, "\n")
		rend.quoteLevel--
		io.WriteString(w, "\n")
		return blackfriday.GoToNext
	}



@@ 212,8 219,11 @@ func (rend *unwrapRenderer) renderPar(w io.Writer, node *blackfriday.Node, enter
	}

	// If we're in a block quote, render the starting mark.
	for i := 0; i < rend.quoteLevel; i++ {
		io.WriteString(w, ">")
	}
	if rend.quoteLevel > 0 {
		io.WriteString(w, "> ")
		io.WriteString(w, " ")
	}

	// TODO: this is jank, but I couldn't figure out how to put two lines between