@@ -25,6 +25,7 @@ import (
2525
2626 "github.com/gohugoio/hugo/markup/converter"
2727 "github.com/gohugoio/hugo/markup/internal"
28+ "github.com/gohugoio/hugo/markup/rst/rst_config"
2829)
2930
3031// Provider is the package entry point.
@@ -81,10 +82,10 @@ func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext)
8182 // handle Windows manually because it doesn't do shebangs
8283 if runtime .GOOS == "windows" {
8384 pythonBinary , _ := internal .GetPythonBinaryAndExecPath ()
84- args := []string {binaryPath , "--leave-comments" , "--initial-header-level=2" }
85+ args := append ( []string {binaryPath }, c . parseArgs () ... )
8586 result , err = internal .ExternallyRenderContent (c .cfg , ctx , src , pythonBinary , args )
8687 } else {
87- args := [] string { "--leave-comments" , "--initial-header-level=2" }
88+ args := c . parseArgs ()
8889 result , err = internal .ExternallyRenderContent (c .cfg , ctx , src , binaryName , args )
8990 }
9091
@@ -106,6 +107,36 @@ func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext)
106107 return result [bodyStart + 7 : bodyEnd ], err
107108}
108109
110+ func (c * rstConverter ) parseArgs () []string {
111+ cfg := rst_config .Default
112+ if c .cfg .Conf != nil {
113+ cfg = c .cfg .MarkupConfig ().RST
114+ }
115+
116+ if cfg .SyntaxHighlight != rst_config .CliDefault .SyntaxHighlight && ! rst_config .AllowedSyntaxHighlight [cfg .SyntaxHighlight ] {
117+ if c .cfg .Logger != nil {
118+ c .cfg .Logger .Errorf (
119+ "Unsupported reStructuredText value %q for option %q was passed in and will be ignored." ,
120+ cfg .SyntaxHighlight ,
121+ "syntaxHighlight" ,
122+ )
123+ }
124+ cfg .SyntaxHighlight = rst_config .CliDefault .SyntaxHighlight
125+ }
126+
127+ return parseArgs (cfg )
128+ }
129+
130+ func parseArgs (cfg rst_config.Config ) []string {
131+ args := []string {"--leave-comments" , "--initial-header-level=2" }
132+
133+ if cfg .SyntaxHighlight != rst_config .CliDefault .SyntaxHighlight && rst_config .AllowedSyntaxHighlight [cfg .SyntaxHighlight ] {
134+ args = append (args , "--syntax-highlight=" + cfg .SyntaxHighlight )
135+ }
136+
137+ return args
138+ }
139+
109140var rst2Binaries = []string {"rst2html" , "rst2html.py" }
110141
111142func getRstBinaryNameAndPath () (string , string ) {
0 commit comments