Add Asciidoc shortcode test

Fixes #2249
This commit is contained in:
Bjørn Erik Pedersen
2016-07-04 00:33:08 +02:00
parent 6c0f705217
commit 5388211c11
2 changed files with 28 additions and 8 deletions

View File

@@ -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, "...")