From 4b7319ad908ef6ad9646e9af7bae2d6bbc2302d0 Mon Sep 17 00:00:00 2001 From: Peter Bakkum Date: Wed, 17 Jan 2024 07:31:49 -0800 Subject: [PATCH] Fixing markdown block formatting --- util/util.go | 2 +- util/util_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/util.go b/util/util.go index 5973527..d9b3621 100644 --- a/util/util.go +++ b/util/util.go @@ -356,7 +356,7 @@ func (this *StyleCodeblocksWriter) Write(p []byte) (n int, err error) { case STATE_THREE_TICKS: if char == '\n' { this.state = STATE_BLOCK_NEWLINE - toWrite.Write([]byte("\n")) + toWrite.WriteByte('\r') this.blockBuffer = new(bytes.Buffer) } else { // append to suffix diff --git a/util/util_test.go b/util/util_test.go index 99a25c1..5a6cead 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -60,7 +60,7 @@ Foo` writer.Write([]byte(testStr)) - expected := "Hello\n\nconsole.log('Hi');\r\x1b[38;5;231mconsole.log('Hi');\x1b[0m\nNORMAL\nFoo" + expected := "Hello\n\rconsole.log('Hi');\r\x1b[38;5;231mconsole.log('Hi');\x1b[0m\nNORMAL\nFoo" // assert buffer equals expected assert.Equal(t, expected, buffer.String()) @@ -79,7 +79,7 @@ Foo` writer.Write([]byte(testStr)) - expected := "Hello\n\nconsole.log(1);\r\x1b[38;5;148mconsole\x1b[0m\x1b[38;5;231m.\x1b[0m\x1b[38;5;148mlog\x1b[0m\x1b[38;5;231m(\x1b[0m\x1b[38;5;141m1\x1b[0m\x1b[38;5;231m);\x1b[0m\nNORMAL\nFoo" + expected := "Hello\n\rconsole.log(1);\r\x1b[38;5;148mconsole\x1b[0m\x1b[38;5;231m.\x1b[0m\x1b[38;5;148mlog\x1b[0m\x1b[38;5;231m(\x1b[0m\x1b[38;5;141m1\x1b[0m\x1b[38;5;231m);\x1b[0m\nNORMAL\nFoo" // assert buffer equals expected assert.Equal(t, expected, buffer.String()) @@ -127,7 +127,7 @@ Foo` writer.Write([]byte(testStr)) - expected := "Hello\n\n \n console.log(1);\r\x1b[38;5;231m \x1b[0m\x1b[38;5;148mconsole\x1b[0m\x1b[38;5;231m.\x1b[0m\x1b[38;5;148mlog\x1b[0m\x1b[38;5;231m(\x1b[0m\x1b[38;5;141m1\x1b[0m\x1b[38;5;231m);\x1b[0m\n NORMAL\nFoo" + expected := "Hello\n\n \r console.log(1);\r\x1b[38;5;231m \x1b[0m\x1b[38;5;148mconsole\x1b[0m\x1b[38;5;231m.\x1b[0m\x1b[38;5;148mlog\x1b[0m\x1b[38;5;231m(\x1b[0m\x1b[38;5;141m1\x1b[0m\x1b[38;5;231m);\x1b[0m\n NORMAL\nFoo" // assert buffer equals expected assert.Equal(t, expected, buffer.String())