diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index 2ddb553342aa6..af3376e8d7127 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -29,12 +29,6 @@ import ( // don't index files larger than this many bytes for performance purposes const sizeLimit = 1024 * 1024 -// newLineInHTML is the HTML entity to be used for newline in HTML content, if it's empty then the original "\n" is kept -// this option is here for 2 purposes: -// (1) make it easier to switch back to the original "\n" if there is any compatibility issue in the future -// (2) make it clear to do tests: " " is the real newline for rendering, '\n' is ignorable/trim-able and could be ignored -var newLineInHTML = " " - var ( // For custom user mapping highlightMapping = map[string]string{} @@ -200,9 +194,6 @@ func File(fileName, language string, code []byte) ([]string, error) { for i := 1; i < len(lines); i++ { line := lines[i] line = strings.TrimSuffix(line, "") - if newLineInHTML != "" && line != "" && line[len(line)-1] == '\n' { - line = line[:len(line)-1] + newLineInHTML - } m = append(m, line) } return m, nil @@ -222,9 +213,6 @@ func PlainText(code []byte) []string { break } s := gohtml.EscapeString(content) - if newLineInHTML != "" && s != "" && s[len(s)-1] == '\n' { - s = s[:len(s)-1] + newLineInHTML - } m = append(m, s) } return m diff --git a/modules/highlight/highlight_test.go b/modules/highlight/highlight_test.go index d37d81ff6a313..bb035110b9df7 100644 --- a/modules/highlight/highlight_test.go +++ b/modules/highlight/highlight_test.go @@ -16,12 +16,6 @@ func lines(s string) []string { } func TestFile(t *testing.T) { - defaultNewLineInHTML := newLineInHTML - defer func() { - newLineInHTML = defaultNewLineInHTML - }() - - newLineInHTML = " " tests := []struct { name string code string @@ -93,20 +87,9 @@ c=2 assert.EqualValues(t, expected, actual) }) } - - newLineInHTML = "" - out, err := File("test-original-newline.py", "", []byte("a=1\n")) - assert.NoError(t, err) - assert.EqualValues(t, `a=1`+"\n", strings.Join(out, "")) } func TestPlainText(t *testing.T) { - defaultNewLineInHTML := newLineInHTML - defer func() { - newLineInHTML = defaultNewLineInHTML - }() - - newLineInHTML = " " tests := []struct { name string code string @@ -170,8 +153,4 @@ c=2`), assert.EqualValues(t, expected, actual) }) } - - newLineInHTML = "" - out := PlainText([]byte("a=1\n")) - assert.EqualValues(t, "a=1\n", strings.Join(out, "")) }