diff --git a/tags/highlight.go b/tags/highlight.go index 8bc4253..6a3bc70 100644 --- a/tags/highlight.go +++ b/tags/highlight.go @@ -4,8 +4,10 @@ import ( "bytes" "fmt" "html" + "io/fs" "os" "os/exec" + "path/filepath" "regexp" "strings" @@ -48,12 +50,12 @@ func highlightTag(rc render.Context) (string, error) { } return buf.String(), nil }) - if e, ok := err.(*exec.Error); ok { - if e.Err == exec.ErrNotFound { + if pathErr, ok := err.(*fs.PathError); ok { + if filepath.Base(pathErr.Path) == pygmentizeCmd { r, err = ``+html.EscapeString(s)+``, nil if !warnedMissingPygmentize { warnedMissingPygmentize = true - _, err = fmt.Fprintf(os.Stdout, "%s\nThe {%% highlight %%} tag will use instead\n", err) + _, err = fmt.Fprintf(os.Stdout, "Error: %s\nRun `pip install Pygments` to install %s.\nThe {%% highlight %%} tag will use instead\n", pathErr, pygmentizeCmd) } } }