diff --git a/freeze_test.go b/freeze_test.go index 53bd6c0d..f7997101 100644 --- a/freeze_test.go +++ b/freeze_test.go @@ -256,6 +256,11 @@ func TestFreezeConfigurations(t *testing.T) { flags: []string{"--wrap", "80", "--width", "600"}, output: "wrap", }, + { + input: "test/input/zprofile", + flags: []string{"--wrap", "80", "--width", "600"}, + output: "wrap", + }, } err := os.RemoveAll("test/output/svg") diff --git a/main.go b/main.go index 53027730..4016f7a6 100644 --- a/main.go +++ b/main.go @@ -157,6 +157,11 @@ func main() { printErrorFatal("File not found", err) } lexer = lexers.Get(config.Input) + if lexer == nil { + // cannot get/match from filename alone + // pass the content for one more attempt to identify + lexer = lexers.Analyse(input) + } } if config.Language != "" { diff --git a/test/golden/png/zprofile-base.png b/test/golden/png/zprofile-base.png new file mode 100644 index 00000000..643dd528 --- /dev/null +++ b/test/golden/png/zprofile-base.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:209135e7aeda69c5fe26a23059b7b2dee1eb925577b948227a3ba5831d443ed3 +size 238254 diff --git a/test/golden/png/zprofile-full.png b/test/golden/png/zprofile-full.png new file mode 100644 index 00000000..7bc4b095 --- /dev/null +++ b/test/golden/png/zprofile-full.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1467ebb90273d6ec13d1ab9ad725afd11e3077d805c9c0c79ec49c2265516569 +size 575429 diff --git a/test/golden/svg/zprofile-base.svg b/test/golden/svg/zprofile-base.svg new file mode 100644 index 00000000..d64213d0 --- /dev/null +++ b/test/golden/svg/zprofile-base.svg @@ -0,0 +1,21 @@ + + + + + +export WHERE=a_zsh_script_without_suffix + +foobar() { +  echo "Hello, because unfortunately zprofile filename does not Get/Match a lexer +  so we're using Lexer.Analyse to read this content to guess language is Shell" +} + + + diff --git a/test/golden/svg/zprofile-full.svg b/test/golden/svg/zprofile-full.svg new file mode 100644 index 00000000..16c4117e --- /dev/null +++ b/test/golden/svg/zprofile-full.svg @@ -0,0 +1,21 @@ + + + + + +export WHERE=a_zsh_script_without_suffix + +foobar() { +  echo "Hello, because unfortunately zprofile filename does not Get/Match a lexer +  so we're using Lexer.Analyse to read this content to guess language is Shell" +} + + + diff --git a/test/input/zprofile b/test/input/zprofile new file mode 100644 index 00000000..83e6679b --- /dev/null +++ b/test/input/zprofile @@ -0,0 +1,6 @@ +export WHERE=a_zsh_script_without_suffix + +foobar() { + echo "Hello, because unfortunately zprofile filename does not Get/Match a lexer + so we're using Lexer.Analyse to read this content to guess language is Shell" +}