Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-07-04 11:49:20 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-07-04 11:49:20 +0300
commite6d97c4fcadc1d7c843f102cd6500a3060e2a5c3 (patch)
treeafec652cbc4e8920215b3dc3e374c647bc4d7b73 /helpers
parent5388211c1158b81725af04152c6e73eddc1435a0 (diff)
Add Rst shortcode test
Fixes #2253
Diffstat (limited to 'helpers')
-rw-r--r--helpers/content.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/helpers/content.go b/helpers/content.go
index 94cc3e853..709dc8a97 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -469,6 +469,7 @@ func getAsciidocExecPath() string {
return path
}
+// HasAsciidoc returns whether Asciidoctor or Asciidoc is installed on this computer.
func HasAsciidoc() bool {
return getAsciidocExecPath() != ""
}
@@ -497,20 +498,35 @@ func getAsciidocContent(content []byte) string {
return out.String()
}
-// getRstContent calls the Python script rst2html as an external helper
-// to convert reStructuredText content to HTML.
-func getRstContent(content []byte) string {
- cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1)
+// HasRst returns whether rst2html is installed on this computer.
+func HasRst() bool {
+ return getRstExecPath() != ""
+}
+func getRstExecPath() string {
path, err := exec.LookPath("rst2html")
if err != nil {
path, err = exec.LookPath("rst2html.py")
if err != nil {
- jww.ERROR.Println("rst2html / rst2html.py not found in $PATH: Please install.\n",
- " Leaving reStructuredText content unrendered.")
- return (string(content))
+ return ""
}
}
+ return path
+}
+
+// getRstContent calls the Python script rst2html as an external helper
+// to convert reStructuredText content to HTML.
+func getRstContent(content []byte) string {
+ cleanContent := bytes.Replace(content, SummaryDivider, []byte(""), 1)
+
+ path := getRstExecPath()
+
+ if path == "" {
+ jww.ERROR.Println("rst2html / rst2html.py not found in $PATH: Please install.\n",
+ " Leaving reStructuredText content unrendered.")
+ return (string(content))
+
+ }
cmd := exec.Command(path, "--leave-comments")
cmd.Stdin = bytes.NewReader(cleanContent)