Use Monaco Editor to create notes. Support syntax highlighting. Store the language with the note in the database to later support syntax highlighting in a note web view. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
b45c3e3253
commit
c54f32495b
9 changed files with 170 additions and 24 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ReadConfig(file string, config interface{}) error {
|
||||
|
@ -109,3 +110,10 @@ func ReturnError(logger *slog.Logger, message string, err error) int {
|
|||
}
|
||||
return RC_ERROR
|
||||
}
|
||||
|
||||
func ToLowerStringSlice(src []string) (dst []string) {
|
||||
for _, s := range src {
|
||||
dst = append(dst, strings.ToLower(s))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package internal
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -38,3 +39,49 @@ func TestHumanDuration(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestToLowerStringsSlice(t *testing.T) {
|
||||
input := []string{
|
||||
"Text",
|
||||
"CSS",
|
||||
"Dockerfile",
|
||||
"Go",
|
||||
"HCL",
|
||||
"HTML",
|
||||
"Javascript",
|
||||
"JSON",
|
||||
"Markdown",
|
||||
"Perl",
|
||||
"Python",
|
||||
"Ruby",
|
||||
"Rust",
|
||||
"Shell",
|
||||
"SQL",
|
||||
"YAML",
|
||||
}
|
||||
expected := []string{
|
||||
"text",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"go",
|
||||
"hcl",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"markdown",
|
||||
"perl",
|
||||
"python",
|
||||
"ruby",
|
||||
"rust",
|
||||
"shell",
|
||||
"sql",
|
||||
"yaml",
|
||||
}
|
||||
|
||||
got := ToLowerStringSlice(input)
|
||||
if slices.Compare(got, expected) != 0 {
|
||||
t.Errorf("got '%s', want '%s'", got, expected)
|
||||
} else {
|
||||
t.Logf("got '%s', want '%s'", got, expected)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue