committing some old stuff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blockquote.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,13 @@
+func lexBlockQuote(l *lexer) stateFunc { + // on our first call we need to move past the opening double space + l.pos += len(tokenBlockQuote) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blockquote_test.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,27 @@
+func TestBlockQuote(t *testing.T) { + input := " block quote" + item{typ: itemBlockQuote, val: "block quote"}, + tokenTest(t, input, items) +func TestBlockQuoteMultipleLines(t *testing.T) { + input := " line 1\r\n line2" + item{typ: itemBlockQuote, val: "line1 line2"}, + tokenTest(t, input, items) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/break.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,19 @@
+func lexBreak(l *lexer) stateFunc { + l.pos += len(tokenBreakMacro) +func lexBreakSlash(l *lexer) stateFunc { + l.pos += len(tokenBreakCreole) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/break_test.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,53 @@
+func TestBreakMacro(t *testing.T) { + item{typ: itemText, val: "Line 1"}, + item{typ: itemText, val: "Line 2"}, + for _, input := range inputs { + tokenTest(t, input, items) +func TestBreakCreole(t *testing.T) { + input := "Line 1 \\\\ Line 2" + item{typ: itemText, val: "Line 1 "}, + item{typ: itemText, val: " Line 2"}, + tokenTest(t, input, items) +func TestBreakMixed(t *testing.T) { + input := "Line [[br]] break Line \\\\ break" + item{typ: itemText, val: "Line "}, + item{typ: itemText, val: " break Line "}, + item{typ: itemText, val: " break"}, + tokenTest(t, input, items) --- a/lexer.go Mon Aug 31 16:51:05 2020 -0500
+++ b/lexer.go Fri Aug 05 01:49:11 2022 -0500
@@ -20,6 +20,8 @@
func (l *lexer) next() (r rune) {
--- a/statefunc.go Mon Aug 31 16:51:05 2020 -0500
+++ b/statefunc.go Fri Aug 05 01:49:11 2022 -0500
@@ -29,6 +29,9 @@
tokenHeader5Close = " ====="
tokenHeader6Open = "====== "
tokenHeader6Close = " ======"
+ tokenBreakMacro = "[[br]]" + tokenBreakCreole = "\\\\" func lexEof(l *lexer) stateFunc {
@@ -54,6 +57,8 @@
} else if strings.HasPrefix(start, tokenCommentOpen) {
+ } else if strings.HasPrefix(start, tokenBlockQuote) { @@ -67,6 +72,10 @@
if strings.HasPrefix(start, tokenMonospaceBraceOpen) {
nextState = lexMonospaceBrace
+ } else if hasPrefix(start, tokenBreakMacro) { + } else if strings.HasPrefix(start, tokenBreakCreole) { + nextState = lexBreakSlash --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,13 @@
+func hasPrefix(str, prefix string) bool { + if len(prefix) > len(str) { + return strings.HasPrefix(strings.ToLower(str[:len(prefix)]), prefix) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/util_test.go Fri Aug 05 01:49:11 2022 -0500
@@ -0,0 +1,28 @@
+ "github.com/stretchr/testify/assert" +func TestHasPrefixSimple(t *testing.T) { + tests := map[string]bool{ + for str, exp := range tests { + assert.Equal(t, hasPrefix(str, "foo"), exp)