aboutsummaryrefslogtreecommitdiffhomepage
path: root/mpaste.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-01-12 00:42:15 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-01-12 00:42:15 +0100
commit641fe408b1b9b45d1dc20905d8ec3c00cd4fc804 (patch)
tree8acc6ee7ca4badff69a392812eb9159b017e97a6 /mpaste.go
parentfc0b71e67c9165978edab7cadda066a129bef78f (diff)
Add support for customizable tab widths
Diffstat (limited to 'mpaste.go')
-rw-r--r--mpaste.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/mpaste.go b/mpaste.go
index f105c2b..b5de948 100644
--- a/mpaste.go
+++ b/mpaste.go
@@ -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")
}