@@ -544,36 +544,58 @@ func truncateWordsToWholeSentenceOld(content string, max int) (string, bool) {
544544}
545545
546546func getAsciidocExecPath () string {
547- path , err := exec .LookPath ("asciidoctor " )
547+ path , err := exec .LookPath ("asciidoc " )
548548 if err != nil {
549- path , err = exec .LookPath ("asciidoc" )
550- if err != nil {
551- return ""
552- }
549+ return ""
553550 }
554551 return path
555552}
556553
557- // HasAsciidoc returns whether Asciidoctor or Asciidoc is installed on this computer.
554+ // HasAsciidoc returns whether Asciidoc is installed on this computer.
558555func HasAsciidoc () bool {
559556 return getAsciidocExecPath () != ""
560557}
561558
559+ func getAsciidoctorExecPath () string {
560+ path , err := exec .LookPath ("asciidoctor" )
561+ if err != nil {
562+ return ""
563+ }
564+ return path
565+ }
566+
567+ // HasAsciidoctor returns whether Asciidoctor is installed on this computer.
568+ func HasAsciidoctor () bool {
569+ return getAsciidoctorExecPath () != ""
570+ }
571+
562572// getAsciidocContent calls asciidoctor or asciidoc as an external helper
563573// to convert AsciiDoc content to HTML.
564574func getAsciidocContent (ctx * RenderingContext ) []byte {
565575 content := ctx .Content
566576 cleanContent := bytes .Replace (content , SummaryDivider , []byte ("" ), 1 )
567577
568- path := getAsciidocExecPath ()
578+ var isAsciidoctor bool
579+ path := getAsciidoctorExecPath ()
569580 if path == "" {
570- jww .ERROR .Println ("asciidoctor / asciidoc not found in $PATH: Please install.\n " ,
571- " Leaving AsciiDoc content unrendered." )
572- return content
581+ path = getAsciidocExecPath ()
582+ if path == "" {
583+ jww .ERROR .Println ("asciidoctor / asciidoc not found in $PATH: Please install.\n " ,
584+ " Leaving AsciiDoc content unrendered." )
585+ return content
586+ }
587+ } else {
588+ isAsciidoctor = true
573589 }
574590
575591 jww .INFO .Println ("Rendering" , ctx .DocumentName , "with" , path , "..." )
576- cmd := exec .Command (path , "--no-header-footer" , "--safe" , "-" )
592+ args := []string {"--no-header-footer" , "--safe" }
593+ if isAsciidoctor {
594+ // asciidoctor-specific arg to show stack traces on errors
595+ args = append (args , "--trace" )
596+ }
597+ args = append (args , "-" )
598+ cmd := exec .Command (path , args ... )
577599 cmd .Stdin = bytes .NewReader (cleanContent )
578600 var out , cmderr bytes.Buffer
579601 cmd .Stdout = & out
0 commit comments