Enable inline css styles if -style argument is given.
This commit is contained in:
parent
cd31fa00c5
commit
a22809f00e
22
main.go
22
main.go
|
@ -56,13 +56,17 @@ func highlight(w io.Writer, source, lexer, style string) error {
|
|||
}
|
||||
l = chroma.Coalesce(l)
|
||||
|
||||
// Determine formatter.
|
||||
f := html.New(html.WithClasses(true), html.TabWidth(4))
|
||||
|
||||
// Determine style.
|
||||
s := styles.Get(style)
|
||||
if s == nil {
|
||||
s = styles.Fallback
|
||||
// Determine formatter and style, depending on whether a specific style is
|
||||
// requested. If no style is requestd, use classes instead of inline css,
|
||||
// leaving the CSS handling to the consumer.
|
||||
var f *html.Formatter
|
||||
var s *chroma.Style
|
||||
if style == "" {
|
||||
f = html.New(html.WithClasses(true))
|
||||
s = new(chroma.Style)
|
||||
} else {
|
||||
f = html.New()
|
||||
s = styles.Get(style)
|
||||
}
|
||||
|
||||
it, err := l.Tokenise(nil, source)
|
||||
|
@ -72,11 +76,11 @@ func highlight(w io.Writer, source, lexer, style string) error {
|
|||
return f.Format(w, s, it)
|
||||
}
|
||||
|
||||
const Version = "0.0"
|
||||
const Version = "0.1"
|
||||
|
||||
func main() {
|
||||
css := flag.String("css", "", "Path to a CSS import to include at the beginning of the output")
|
||||
style := flag.String("style", "native", "CSS style to use")
|
||||
style := flag.String("style", "", "CSS style to use")
|
||||
version := flag.Bool("version", false, "Print the version string")
|
||||
v := flag.Bool("v", false, "Print the version string")
|
||||
flag.Parse()
|
||||
|
|
Loading…
Reference in New Issue