summaryrefslogtreecommitdiffstats
path: root/helpers/content.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-07-04 00:33:08 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-07-04 00:33:08 +0200
commit5388211c1158b81725af04152c6e73eddc1435a0 (patch)
tree93d1ffdb8fd47b617637ae7528d57d47727dc228 /helpers/content.go
parent6c0f705217b65c7e91fe22c5b8ca0c3f8b1bf33a (diff)
Add Asciidoc shortcode test
Fixes #2249
Diffstat (limited to 'helpers/content.go')
-rw-r--r--helpers/content.go28
1 files changed, 20 insertions, 8 deletions
diff --git a/helpers/content.go b/helpers/content.go
index 7a6f361c8..94cc3e853 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -458,20 +458,32 @@ func TruncateWordsToWholeSentence(words []string, max int) (string, bool) {
return strings.Join(words[:max], " "), true
}
-// 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)
-
+func getAsciidocExecPath() string {
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))
+ 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 := 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, "...")
cmd := exec.Command(path, "--no-header-footer", "--safe", "-")