Skip to content

Commit 025e3d9

Browse files
committed
remove newLineInHTML = "
"
1 parent c8107f8 commit 025e3d9

File tree

2 files changed

+0
-33
lines changed

2 files changed

+0
-33
lines changed

modules/highlight/highlight.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ import (
2929
// don't index files larger than this many bytes for performance purposes
3030
const sizeLimit = 1024 * 1024
3131

32-
// newLineInHTML is the HTML entity to be used for newline in HTML content, if it's empty then the original "\n" is kept
33-
// this option is here for 2 purposes:
34-
// (1) make it easier to switch back to the original "\n" if there is any compatibility issue in the future
35-
// (2) make it clear to do tests: "
" is the real newline for rendering, '\n' is ignorable/trim-able and could be ignored
36-
var newLineInHTML = "
"
37-
3832
var (
3933
// For custom user mapping
4034
highlightMapping = map[string]string{}
@@ -200,9 +194,6 @@ func File(fileName, language string, code []byte) ([]string, error) {
200194
for i := 1; i < len(lines); i++ {
201195
line := lines[i]
202196
line = strings.TrimSuffix(line, "</span></span>")
203-
if newLineInHTML != "" && line != "" && line[len(line)-1] == '\n' {
204-
line = line[:len(line)-1] + newLineInHTML
205-
}
206197
m = append(m, line)
207198
}
208199
return m, nil
@@ -222,9 +213,6 @@ func PlainText(code []byte) []string {
222213
break
223214
}
224215
s := gohtml.EscapeString(content)
225-
if newLineInHTML != "" && s != "" && s[len(s)-1] == '\n' {
226-
s = s[:len(s)-1] + newLineInHTML
227-
}
228216
m = append(m, s)
229217
}
230218
return m

modules/highlight/highlight_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ func lines(s string) []string {
1616
}
1717

1818
func TestFile(t *testing.T) {
19-
defaultNewLineInHTML := newLineInHTML
20-
defer func() {
21-
newLineInHTML = defaultNewLineInHTML
22-
}()
23-
24-
newLineInHTML = "&#10;"
2519
tests := []struct {
2620
name string
2721
code string
@@ -93,20 +87,9 @@ c=2
9387
assert.EqualValues(t, expected, actual)
9488
})
9589
}
96-
97-
newLineInHTML = ""
98-
out, err := File("test-original-newline.py", "", []byte("a=1\n"))
99-
assert.NoError(t, err)
100-
assert.EqualValues(t, `<span class="n">a</span><span class="o">=</span><span class="mi">1</span>`+"\n", strings.Join(out, ""))
10190
}
10291

10392
func TestPlainText(t *testing.T) {
104-
defaultNewLineInHTML := newLineInHTML
105-
defer func() {
106-
newLineInHTML = defaultNewLineInHTML
107-
}()
108-
109-
newLineInHTML = "&#10;"
11093
tests := []struct {
11194
name string
11295
code string
@@ -170,8 +153,4 @@ c=2`),
170153
assert.EqualValues(t, expected, actual)
171154
})
172155
}
173-
174-
newLineInHTML = ""
175-
out := PlainText([]byte("a=1\n"))
176-
assert.EqualValues(t, "a=1\n", strings.Join(out, ""))
177156
}

0 commit comments

Comments
 (0)