diff --git a/.gitignore b/.gitignore index 00a3413..2531ed9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .env -docker-compose.yml \ No newline at end of file +docker-compose.yml +.DS_Store +*bin \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f944eb2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "." + } + ] +} \ No newline at end of file diff --git a/env/checks.go b/env/checks.go index cd46d96..74b583f 100644 --- a/env/checks.go +++ b/env/checks.go @@ -3,9 +3,12 @@ package env import ( "fmt" "os" + + "github.com/joho/godotenv" ) func RunChecks() { + godotenv.Load(".env") checkEnv("APP_URL") } diff --git a/go.mod b/go.mod index a89b966..1a2e400 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect github.com/goccy/go-json v0.10.0 // indirect + github.com/joho/godotenv v1.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/mattn/go-isatty v0.0.16 // indirect diff --git a/go.sum b/go.sum index b46cd10..e210ac8 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= diff --git a/src/utils/syntax.go b/src/utils/syntax.go index 934283c..cb4c4ea 100644 --- a/src/utils/syntax.go +++ b/src/utils/syntax.go @@ -7,13 +7,11 @@ import ( "regexp" "strings" - "github.com/alecthomas/chroma/formatters" + html_formatter "github.com/alecthomas/chroma/formatters/html" "github.com/alecthomas/chroma/lexers" "github.com/alecthomas/chroma/styles" ) -var plainFormattedCodeRegex = regexp.MustCompile(`(?s)
(.+?)
`)
-
func HighlightSyntaxViaContent(content string) (htmlOut string) {
content = html.UnescapeString(content)
@@ -32,10 +30,7 @@ func HighlightSyntaxViaContent(content string) (htmlOut string) {
style = styles.Fallback
}
- formatter := formatters.Get("html")
- if formatter == nil {
- formatter = formatters.Fallback
- }
+ formatter := html_formatter.New(html_formatter.PreventSurroundingPre(true), html_formatter.WithClasses(true))
iterator, err := lexer.Tokenise(nil, content)
if err != nil {
@@ -52,14 +47,7 @@ func HighlightSyntaxViaContent(content string) (htmlOut string) {
return
}
- // parse only the ...
part
htmlOut = b.String()
- htmlOut = plainFormattedCodeRegex.FindString(htmlOut)
-
- htmlOut = StripBlockTags(htmlOut)
-
- // remove - htmlOut = strings.Replace(htmlOut, "", "", -1) return }