Skip to content

Commit

Permalink
helpers: Add smarter check for asciidoctor
Browse files Browse the repository at this point in the history
  • Loading branch information
miltador committed Jul 21, 2017
1 parent 6ceb0b4 commit 089b878
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions helpers/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,24 +576,26 @@ func getAsciidocContent(ctx *RenderingContext) []byte {
cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1)

var isAsciidoctor bool
path := getAsciidocExecPath()
path := getAsciidoctorExecPath()
if path == "" {
path := getAsciidoctorExecPath()
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
cmd.Args = append(cmd.Args, "--trace")
args = append(args, "--trace")
}
cmd.Args = append(cmd.Args, "-")
args = append(args, "-")
cmd := exec.Command(path, args...)
cmd.Stdin = bytes.NewReader(cleanContent)
var out, cmderr bytes.Buffer
cmd.Stdout = &out
Expand Down Expand Up @@ -692,7 +694,7 @@ func getRstContent(ctx *RenderingContext) []byte {
}
}

return result[bodyStart+7: bodyEnd]
return result[bodyStart+7 : bodyEnd]
}

func orgRender(ctx *RenderingContext, c ContentSpec) []byte {
Expand Down
2 changes: 1 addition & 1 deletion hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func testAllMarkdownEnginesForPages(t *testing.T,
}{
{"md", func() bool { return true }},
{"mmark", func() bool { return true }},
{"ad", func() bool { return helpers.HasAsciidoc() || helpers.HasAsciidoctor() }},
{"ad", func() bool { return helpers.HasAsciidoctor() || helpers.HasAsciidoc() }},
// TODO(bep) figure a way to include this without too much work.{"html", func() bool { return true }},
{"rst", func() bool { return helpers.HasRst() }},
}
Expand Down
2 changes: 1 addition & 1 deletion hugolib/shortcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ tags:
th := testHelper{s.Cfg, s.Fs, t}

for _, test := range tests {
if strings.HasSuffix(test.contentPath, ".ad") && !helpers.HasAsciidoc() && !helpers.HasAsciidoctor() {
if strings.HasSuffix(test.contentPath, ".ad") && !helpers.HasAsciidoctor() && !helpers.HasAsciidoc() {
fmt.Println("Skip Asciidoc test case as no Asciidoc present.")
continue
} else if strings.HasSuffix(test.contentPath, ".rst") && !helpers.HasRst() {
Expand Down

0 comments on commit 089b878

Please sign in to comment.