diff --git a/helpers/content.go b/helpers/content.go index 7a6f361c8..94cc3e853 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -458,19 +458,31 @@ func TruncateWordsToWholeSentence(words []string, max int) (string, bool) { return strings.Join(words[:max], " "), true } +func getAsciidocExecPath() string { + path, err := exec.LookPath("asciidoctor") + if err != nil { + path, err = exec.LookPath("asciidoc") + if err != nil { + return "" + } + } + return path +} + +func HasAsciidoc() bool { + return getAsciidocExecPath() != "" +} + // getAsciidocContent calls asciidoctor or asciidoc as an external helper // to convert AsciiDoc content to HTML. func getAsciidocContent(content []byte) string { cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1) - path, err := exec.LookPath("asciidoctor") - if err != nil { - path, err = exec.LookPath("asciidoc") - if err != nil { - jww.ERROR.Println("asciidoctor / asciidoc not found in $PATH: Please install.\n", - " Leaving AsciiDoc content unrendered.") - return (string(content)) - } + path := getAsciidocExecPath() + if path == "" { + jww.ERROR.Println("asciidoctor / asciidoc not found in $PATH: Please install.\n", + " Leaving AsciiDoc content unrendered.") + return (string(content)) } jww.INFO.Println("Rendering with", path, "...") diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index a055d0882..79fb0c72e 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -466,6 +466,10 @@ e`, {"sect/doc6.md", "\n```bash\n{{< b >}}\n{{% c %}}\n```\n", filepath.FromSlash("sect/doc6/index.html"), "
b\nc\n
\n"},
+ // #2249
+ {"sect/doc7.ad", `_Shortcodes:_ *b: {{< b >}} c: {{% c %}}*`,
+ filepath.FromSlash("sect/doc7/index.html"),
+ "Shortcodes: b: b c: c
\n