summaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorVasyl Solovei <[email protected]>2017-07-21 12:07:56 +0300
committerAnthony Fok <[email protected]>2017-07-21 03:07:56 -0600
commitb60aa1a504f3fbf9c19a6bf2030fdc7a04ab4a5a (patch)
tree4fa620cbf71488b8bcfc4a52b86221164a0a986b /helpers
parentff433f98133662063cbb16e220fd44c678c82823 (diff)
downloadhugo-b60aa1a504f3fbf9c19a6bf2030fdc7a04ab4a5a.tar.gz
hugo-b60aa1a504f3fbf9c19a6bf2030fdc7a04ab4a5a.zip
helpers: Add --trace to asciidoctor args
This will help to understand and fix errors by seeing stacktrace of an error. See #3714
Diffstat (limited to 'helpers')
-rw-r--r--helpers/content.go44
1 files changed, 33 insertions, 11 deletions
diff --git a/helpers/content.go b/helpers/content.go
index 6db35263f..350d1a685 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -544,36 +544,58 @@ func truncateWordsToWholeSentenceOld(content string, max int) (string, bool) {
}
func getAsciidocExecPath() string {
- path, err := exec.LookPath("asciidoctor")
+ path, err := exec.LookPath("asciidoc")
if err != nil {
- path, err = exec.LookPath("asciidoc")
- if err != nil {
- return ""
- }
+ return ""
}
return path
}
-// HasAsciidoc returns whether Asciidoctor or Asciidoc is installed on this computer.
+// HasAsciidoc returns whether Asciidoc is installed on this computer.
func HasAsciidoc() bool {
return getAsciidocExecPath() != ""
}
+func getAsciidoctorExecPath() string {
+ path, err := exec.LookPath("asciidoctor")
+ if err != nil {
+ return ""
+ }
+ return path
+}
+
+// HasAsciidoctor returns whether Asciidoctor is installed on this computer.
+func HasAsciidoctor() bool {
+ return getAsciidoctorExecPath() != ""
+}
+
// getAsciidocContent calls asciidoctor or asciidoc as an external helper
// to convert AsciiDoc content to HTML.
func getAsciidocContent(ctx *RenderingContext) []byte {
content := ctx.Content
cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1)
- path := getAsciidocExecPath()
+ var isAsciidoctor bool
+ path := getAsciidoctorExecPath()
if path == "" {
- jww.ERROR.Println("asciidoctor / asciidoc not found in $PATH: Please install.\n",
- " Leaving AsciiDoc content unrendered.")
- return content
+ path = getAsciidocExecPath()
+ if path == "" {
+ jww.ERROR.Println("asciidoctor / asciidoc not found in $PATH: Please install.\n",
+ " Leaving AsciiDoc content unrendered.")
+ return content
+ }
+ } else {
+ isAsciidoctor = true
}
jww.INFO.Println("Rendering", ctx.DocumentName, "with", path, "...")
- cmd := exec.Command(path, "--no-header-footer", "--safe", "-")
+ args := []string{"--no-header-footer", "--safe"}
+ if isAsciidoctor {
+ // asciidoctor-specific arg to show stack traces on errors
+ args = append(args, "--trace")
+ }
+ args = append(args, "-")
+ cmd := exec.Command(path, args...)
cmd.Stdin = bytes.NewReader(cleanContent)
var out, cmderr bytes.Buffer
cmd.Stdout = &out