Make syntax highlighting optional
This commit is contained in:
parent
e9f82edfdd
commit
7bcd035ffe
14
main.go
14
main.go
|
@ -2,12 +2,13 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/ewhal/pygments"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/ewhal/pygments"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -16,6 +17,7 @@ const (
|
|||
LENGTH = 4
|
||||
TEXT = "$ <command> | curl -F 'p=<-' lang='python'" + ADDRESS + "\n"
|
||||
PORT = ":8080"
|
||||
SYNTAX = false
|
||||
)
|
||||
|
||||
func check(err error) {
|
||||
|
@ -68,10 +70,12 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, err.Error(), 500)
|
||||
}
|
||||
|
||||
if param2 != "" {
|
||||
highlight := pygments.Highlight(string(s), param2, "html", "full, style=autumn,linenos=True, lineanchors=True,anchorlinenos=True,", "utf-8")
|
||||
io.WriteString(w, string(highlight))
|
||||
if SYNTAX == true {
|
||||
if param2 != "" {
|
||||
highlight := pygments.Highlight(string(s), param2, "html", "full, style=autumn,linenos=True, lineanchors=True,anchorlinenos=True,", "utf-8")
|
||||
io.WriteString(w, string(highlight))
|
||||
|
||||
}
|
||||
} else {
|
||||
io.WriteString(w, string(s))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue