Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lexers.Analyse does not recognise Dockerfile, whereas quick.Highlight does #876

Closed
paololazzari opened this issue Oct 22, 2023 · 1 comment

Comments

@paololazzari
Copy link

paololazzari commented Oct 22, 2023

Given Dockerfile:

$ cat Dockerfile
FROM ubuntu
RUN echo hello world

then:

func main() {
	f, err := os.Open("Dockerfile")
	if err != nil {
		log.Panicf("failed reading file: %s", err)
	}
	defer f.Close()

	contents, err := ioutil.ReadAll(f)
	l := lexers.Analyse(string(contents))
	fmt.Println(l)
}

returns <nil> .

Whereas if I run:

func main() {
  fmt.Println(quick.Highlight(os.Stdout, "FROM ubuntu\nRUN echo hello world\n", "docker", "html", "monokai"))
}

this generates an html where the Dockerfile is indeed recognised

@alecthomas
Copy link
Owner

That is working as expected. With Analyse Chroma does best effort content analysis to detect the file type, while with quick you're explicitly specifying the file type.

@alecthomas alecthomas closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants