Skip to content

Commit 901ce59

Browse files
committed
code review
1 parent 449999a commit 901ce59

File tree

5 files changed

+10
-38
lines changed

5 files changed

+10
-38
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ globals:
2828
Tribute: false
2929

3030
overrides:
31-
- files: ["web_src/**/*.worker.js", "web_src/js/serviceworker.js"]
31+
- files: ["web_src/js/serviceworker.js"]
3232
env:
3333
worker: true
3434

modules/highlight/highlight.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func NewContext() {
3939
// Code returns a HTML version of code string with chroma syntax highlighting classes
4040
func Code(fileName, code string) string {
4141
NewContext()
42+
// don't highlight over 25kb
43+
if len(code) > 25000 {
44+
return plainText(string(code), numLines)
45+
}
4246
formatter := html.New(html.WithClasses(true),
4347
html.WithLineNumbers(false),
4448
html.PreventSurroundingPre(true),
@@ -80,8 +84,10 @@ func Code(fileName, code string) string {
8084
// File returns map with line lumbers and HTML version of code with chroma syntax highlighting classes
8185
func File(numLines int, fileName string, code []byte) map[int]string {
8286
NewContext()
83-
m := make(map[int]string, numLines)
84-
87+
// don't highlight over 25kb
88+
if len(code) > 25000 {
89+
return plainText(string(code), numLines)
90+
}
8591
formatter := html.New(html.WithClasses(true),
8692
html.WithLineNumbers(false),
8793
html.PreventSurroundingPre(true),
@@ -120,6 +126,7 @@ func File(numLines int, fileName string, code []byte) map[int]string {
120126
}
121127

122128
htmlw.Flush()
129+
m := make(map[int]string, numLines)
123130
for k, v := range strings.SplitN(htmlbuf.String(), "\n", numLines) {
124131
line := k + 1
125132
m[line] = string(v)

package-lock.json

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"webpack-fix-style-only-entries": "0.5.0",
4848
"workbox-routing": "5.1.3",
4949
"workbox-strategies": "5.1.3",
50-
"worker-loader": "2.0.0",
5150
"wrap-ansi": "7.0.0"
5251
},
5352
"devDependencies": {

webpack.config.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,6 @@ module.exports = {
102102
exclude: /node_modules/,
103103
loader: 'vue-loader',
104104
},
105-
{
106-
test: /\.worker\.js$/,
107-
exclude: /monaco/,
108-
use: [
109-
{
110-
loader: 'worker-loader',
111-
options: {
112-
name: '[name].js',
113-
inline: true,
114-
fallback: false,
115-
},
116-
},
117-
],
118-
},
119105
{
120106
test: /\.js$/,
121107
exclude: /node_modules/,

0 commit comments

Comments
 (0)