diff --git a/markup/markup_config/config.go b/markup/markup_config/config.go index be17c7b99..2dccbd6f8 100644 --- a/markup/markup_config/config.go +++ b/markup/markup_config/config.go @@ -111,5 +111,6 @@ var Default = Config{ Bibliography: bibliography.Default, Goldmark: goldmark_config.Default, + Pandoc: pandoc_config.Default, AsciidocExt: asciidocext_config.Default, } diff --git a/markup/pandoc/convert.go b/markup/pandoc/convert.go index a4caea57f..90a4fcc54 100644 --- a/markup/pandoc/convert.go +++ b/markup/pandoc/convert.go @@ -15,6 +15,7 @@ package pandoc import ( + "errors" "strings" "github.com/gohugoio/hugo/common/hexec" @@ -22,7 +23,6 @@ import ( "github.com/mitchellh/mapstructure" "github.com/gohugoio/hugo/identity" - "github.com/gohugoio/hugo/markup/bibliography" "github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/markup/internal" @@ -64,7 +64,7 @@ type pandocConverter struct { } func (c *pandocConverter) Convert(ctx converter.RenderContext) (converter.ResultRender, error) { - b, err := c.getPandocContent(ctx.Src, c.ctx) + b, err := c.getPandocContent(ctx.Src) if err != nil { return nil, err } @@ -76,17 +76,14 @@ func (c *pandocConverter) Supports(feature identity.Identity) bool { } // getPandocContent calls pandoc as an external helper to convert pandoc markdown to HTML. -func (c *pandocConverter) getPandocContent(src []byte) []byte { - logger := c.cfg.Logger +func (c *pandocConverter) getPandocContent(src []byte) ([]byte, error) { pandocPath, pandocFound := getPandocBinaryName() if !pandocFound { - logger.Println("pandoc not found in $PATH: Please install.\n", - " Leaving pandoc content unrendered.") - return src + return nil, errors.New("pandoc not found in $PATH: Please install.") } - var pandocConfig pandoc_config.Config = c.cfg.MarkupConfig.Pandoc - var bibConfig bibliography.Config = c.cfg.MarkupConfig.Bibliography + var pandocConfig pandoc_config.Config = c.cfg.MarkupConfig().Pandoc + var bibConfig bibliography.Config = c.cfg.MarkupConfig().Bibliography if pageParameters, ok := c.docCtx.Document.(paramer); ok { if bibParam, err := pageParameters.Param("bibliography"); err == nil { @@ -111,7 +108,7 @@ func (c *pandocConverter) getPandocContent(src []byte) []byte { arguments = append(arguments, "--resource-path", resourcePath) renderedContent, _ := internal.ExternallyRenderContent(c.cfg, c.docCtx, src, pandocPath, arguments) - return renderedContent + return renderedContent, nil } const pandocBinary = "pandoc" diff --git a/markup/pandoc/pandoc_config/pandoc.go b/markup/pandoc/pandoc_config/pandoc.go index 4c586b754..45d7cc6ad 100644 --- a/markup/pandoc/pandoc_config/pandoc.go +++ b/markup/pandoc/pandoc_config/pandoc.go @@ -69,6 +69,12 @@ type Config struct { ExtraArgs []string } +var Default = Config{ + InputFormat: "markdown", + UseLegacyHtml: false, + UseMathjax: true, +} + func (c *Config) getInputArg() string { var b strings.Builder b.WriteString("--from=")