1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-04-25 12:14:41 +02:00

Simplify configuration of HTML call.

This commit is contained in:
Alec Thomas 2019-11-28 11:20:45 +11:00
parent 3b4f493cc3
commit 2d34ebacdb
2 changed files with 7 additions and 19 deletions

View File

@ -169,24 +169,12 @@ func configureHTMLFormatter(ctx *kong.Context) {
options := []html.Option{ options := []html.Option{
html.TabWidth(cli.HTMLTabWidth), html.TabWidth(cli.HTMLTabWidth),
html.BaseLineNumber(cli.HTMLBaseLine), html.BaseLineNumber(cli.HTMLBaseLine),
} html.ClassPrefix(cli.HTMLPrefix),
if cli.HTMLPrefix != "" { html.WithClasses(!cli.HTMLInlineStyles),
options = append(options, html.ClassPrefix(cli.HTMLPrefix)) html.Standalone(!cli.HTMLOnly),
} html.WithLineNumbers(cli.HTMLLines),
if !cli.HTMLInlineStyles { html.LineNumbersInTable(cli.HTMLLinesTable),
options = append(options, html.WithClasses(true)) html.PreventSurroundingPre(cli.HTMLPreventSurroundingPre),
}
if !cli.HTMLOnly {
options = append(options, html.Standalone(true))
}
if cli.HTMLLines {
options = append(options, html.WithLineNumbers(true))
}
if cli.HTMLLinesTable {
options = append(options, html.LineNumbersInTable(true))
}
if cli.HTMLPreventSurroundingPre {
options = append(options, html.PreventSurroundingPre(true))
} }
if len(cli.HTMLHighlight) > 0 { if len(cli.HTMLHighlight) > 0 {
ranges := [][2]int{} ranges := [][2]int{}

View File

@ -153,7 +153,7 @@ func main() {
} }
ctx := kong.Parse(&cli, kong.Configuration(konghcl.Loader)) ctx := kong.Parse(&cli, kong.Configuration(konghcl.Loader))
log.Println("Starting") log.Printf("Starting on http://%s\n", cli.Bind)
router := mux.NewRouter() router := mux.NewRouter()
router.Handle("/", http.HandlerFunc(index)).Methods("GET") router.Handle("/", http.HandlerFunc(index)).Methods("GET")