mirror of
https://github.com/danog/gojekyll.git
synced 2025-01-22 21:01:18 +01:00
Update code that recognizes missing pymentize to modern golang; add solution message
This commit is contained in:
parent
1cded6031f
commit
831ea531a1
@ -4,8 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -48,12 +50,12 @@ func highlightTag(rc render.Context) (string, error) {
|
|||||||
}
|
}
|
||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
})
|
})
|
||||||
if e, ok := err.(*exec.Error); ok {
|
if pathErr, ok := err.(*fs.PathError); ok {
|
||||||
if e.Err == exec.ErrNotFound {
|
if filepath.Base(pathErr.Path) == pygmentizeCmd {
|
||||||
r, err = `<code>`+html.EscapeString(s)+`</code>`, nil
|
r, err = `<code>`+html.EscapeString(s)+`</code>`, nil
|
||||||
if !warnedMissingPygmentize {
|
if !warnedMissingPygmentize {
|
||||||
warnedMissingPygmentize = true
|
warnedMissingPygmentize = true
|
||||||
_, err = fmt.Fprintf(os.Stdout, "%s\nThe {%% highlight %%} tag will use <code>…</code> instead\n", err)
|
_, err = fmt.Fprintf(os.Stdout, "Error: %s\nRun `pip install Pygments` to install %s.\nThe {%% highlight %%} tag will use <code>…</code> instead\n", pathErr, pygmentizeCmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user