diff options
author | Thomas Voss <mail@thomasvoss.com> | 2022-01-12 00:42:15 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2022-01-12 00:42:15 +0100 |
commit | 641fe408b1b9b45d1dc20905d8ec3c00cd4fc804 (patch) | |
tree | 8acc6ee7ca4badff69a392812eb9159b017e97a6 /mpaste.go | |
parent | fc0b71e67c9165978edab7cadda066a129bef78f (diff) |
Add support for customizable tab widths
Diffstat (limited to 'mpaste.go')
-rw-r--r-- | mpaste.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -37,11 +37,7 @@ var ( user_file string ) -var ( - style = styles.Get("pygments") - formatter = html.New(html.Standalone(true), html.WithClasses(true), - html.WithLineNumbers(true), html.LineNumbersInTable(true)) -) +var style = styles.Get("pygments") func usage() { fmt.Fprintf(os.Stderr, @@ -147,6 +143,11 @@ func syntax_highlighting(w http.ResponseWriter, r *http.Request) { WRITE_HEADER(http.StatusInternalServerError, "Failed to tokenize output") } + tw, err := strconv.Atoi(r.URL.Query().Get("tabs")) + if err != nil { + tw = 8 + } + formatter := html.New(html.Standalone(true), html.WithClasses(true), html.WithLineNumbers(true), html.LineNumbersInTable(true), html.TabWidth(tw)) if err := formatter.Format(w, style, iterator); err != nil { WRITE_HEADER(http.StatusInternalServerError, "Failed to format output") } |