func ExamplePrintWhitespace() { src := []byte(" package main \n\t\n") highlight_go.Print(src, ioutil.Discard, debugPrinter{Printer: syntaxhighlight.HTMLPrinter(syntaxhighlight.DefaultHTMLConfig)}) // Output: // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.Keyword, "package") // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.Plaintext, "main") // Print(syntaxhighlight.Whitespace, " \n\t\n") }
func ExamplePrint() { src := []byte(`package main import "fmt" func main() { fmt.Println("Hey there, Go.") } `) // debugPrinter implements syntaxhighlight.Printer and prints the parameters it's given. p := debugPrinter{Printer: syntaxhighlight.HTMLPrinter(syntaxhighlight.DefaultHTMLConfig)} var buf bytes.Buffer highlight_go.Print(src, &buf, p) io.Copy(os.Stdout, &buf) // Output: // Print(syntaxhighlight.Keyword, "package") // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.Plaintext, "main") // Print(syntaxhighlight.Whitespace, "\n\n") // Print(syntaxhighlight.Keyword, "import") // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.String, "\"fmt\"") // Print(syntaxhighlight.Whitespace, "\n\n") // Print(syntaxhighlight.Keyword, "func") // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.Plaintext, "main") // Print(syntaxhighlight.Plaintext, "(") // Print(syntaxhighlight.Plaintext, ")") // Print(syntaxhighlight.Whitespace, " ") // Print(syntaxhighlight.Plaintext, "{") // Print(syntaxhighlight.Whitespace, "\n\t") // Print(syntaxhighlight.Plaintext, "fmt") // Print(syntaxhighlight.Plaintext, ".") // Print(syntaxhighlight.Plaintext, "Println") // Print(syntaxhighlight.Plaintext, "(") // Print(syntaxhighlight.String, "\"Hey there, Go.\"") // Print(syntaxhighlight.Plaintext, ")") // Print(syntaxhighlight.Whitespace, "\n") // Print(syntaxhighlight.Plaintext, "}") // Print(syntaxhighlight.Whitespace, "\n") // <span class="kwd">package</span> <span class="pln">main</span> // // <span class="kwd">import</span> <span class="str">"fmt"</span> // // <span class="kwd">func</span> <span class="pln">main</span><span class="pln">(</span><span class="pln">)</span> <span class="pln">{</span> // <span class="pln">fmt</span><span class="pln">.</span><span class="pln">Println</span><span class="pln">(</span><span class="str">"Hey there, Go."</span><span class="pln">)</span> // <span class="pln">}</span> }