romannurik / SlidesCodeHighlighter

A little web app that helps you copy+paste syntax-highlighted code into slide decks.
https://romannurik.github.io/SlidesCodeHighlighter/
Apache License 2.0
1.06k stars 92 forks source link

Go does not highlight when specified, but it does with auto-detect #11

Closed dexafree closed 6 years ago

dexafree commented 6 years ago

The title summarizes it.

If you type a sample Go code snippet, and select the Go language, it will not get any highlight.

But if, instead, you choose the "Auto-detect" option, it will get the correct highlighting. It doesn't matter which theme you choose, it happens with every theme.

Here's a sample code:

package main

import "fmt"

type Person struct {
    Name string `json:"name"`
    Age  int    `json:"age"`
}

func (p *Person) Greet() {
    fmt.Println("Hello! My name is", p.Name)
}

func main() {
    p := &Person{
        Name: "Dexafree",
        Age:  25,
    }

    p.Greet()
}

And two screenshots proving the problem:

Auto-detect

Specified

romannurik commented 6 years ago

I think this is working as intended in Google Code Prettify:

From lang-go.js:

 * Go uses a minimal style for highlighting so the below does not distinguish
 * strings, keywords, literals, etc. by design.
 * From a discussion with the Go designers:
 * <pre>
 * On Thursday, July 22, 2010, Mike Samuel <...> wrote:
 * > On Thu, Jul 22, 2010, Rob 'Commander' Pike <...> wrote:
 * >> Personally, I would vote for the subdued style godoc presents at http://golang.org

Not sure if I want to deviate from the upstream repo to fix this..