Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsdizzie committed Jun 28, 2020
1 parent 449999a commit 901ce59
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ globals:
Tribute: false

overrides:
- files: ["web_src/**/*.worker.js", "web_src/js/serviceworker.js"]
- files: ["web_src/js/serviceworker.js"]
env:
worker: true

Expand Down
11 changes: 9 additions & 2 deletions modules/highlight/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func NewContext() {
// Code returns a HTML version of code string with chroma syntax highlighting classes
func Code(fileName, code string) string {
NewContext()
// don't highlight over 25kb
if len(code) > 25000 {
return plainText(string(code), numLines)
}
formatter := html.New(html.WithClasses(true),
html.WithLineNumbers(false),
html.PreventSurroundingPre(true),
Expand Down Expand Up @@ -80,8 +84,10 @@ func Code(fileName, code string) string {
// File returns map with line lumbers and HTML version of code with chroma syntax highlighting classes
func File(numLines int, fileName string, code []byte) map[int]string {
NewContext()
m := make(map[int]string, numLines)

// don't highlight over 25kb
if len(code) > 25000 {
return plainText(string(code), numLines)
}
formatter := html.New(html.WithClasses(true),
html.WithLineNumbers(false),
html.PreventSurroundingPre(true),
Expand Down Expand Up @@ -120,6 +126,7 @@ func File(numLines int, fileName string, code []byte) map[int]string {
}

htmlw.Flush()
m := make(map[int]string, numLines)
for k, v := range strings.SplitN(htmlbuf.String(), "\n", numLines) {
line := k + 1
m[line] = string(v)
Expand Down
20 changes: 0 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"webpack-fix-style-only-entries": "0.5.0",
"workbox-routing": "5.1.3",
"workbox-strategies": "5.1.3",
"worker-loader": "2.0.0",
"wrap-ansi": "7.0.0"
},
"devDependencies": {
Expand Down
14 changes: 0 additions & 14 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,6 @@ module.exports = {
exclude: /node_modules/,
loader: 'vue-loader',
},
{
test: /\.worker\.js$/,
exclude: /monaco/,
use: [
{
loader: 'worker-loader',
options: {
name: '[name].js',
inline: true,
fallback: false,
},
},
],
},
{
test: /\.js$/,
exclude: /node_modules/,
Expand Down

0 comments on commit 901ce59

Please sign in to comment.