Add syntax highlighting for output?


How do I get ahold of the syntax highlighting for a language in Atom?

I’ve got a string that’s the signature of a function in Go. example: func (t *Type) String() string

How do I color this how the IDE is coloring standard Go code in the editor? Or do I have to parse it myself and apply the classes that the IDE is using when it applies the syntax highlighting?



The language-go package is what dictates all highlighting rules for Go files. If you have something that you believe should be added to the language definition, you can contribute to that repository. If you clone the repo and use apm link, you can reload Atom and the core package will be overridden with the one you’re working on


Thanks! Any idea how I would apply that to a particular string of text that’s not a go file?


What is the string of text?


func (t *Type) String() string

I’m writing html and some of the strings (or P elements) are Go code. Trying to get them colored for Go syntax.


If you want to embed Go in HTML files, that would require a custom grammar. It’s not too difficult and I can show you how, but I would have to know where the Go code appears and how Atom would know that it’s Go code instead of just web site content.