aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup/converter
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-11-06 20:10:47 +0100
committerBjørn Erik Pedersen <[email protected]>2019-11-23 14:12:24 +0100
commitbfb9613a14ab2d93a4474e5486d22e52a9d5e2b3 (patch)
tree81c4dbd10505e952489e1dbcf1d7bafc88b57c28 /markup/converter
parenta3fe5e5e35f311f22b6b4fc38abfcf64cd2c7d6f (diff)
downloadhugo-bfb9613a14ab2d93a4474e5486d22e52a9d5e2b3.tar.gz
hugo-bfb9613a14ab2d93a4474e5486d22e52a9d5e2b3.zip
Add Goldmark as the new default markdown handler
This commit adds the fast and CommonMark compliant Goldmark as the new default markdown handler in Hugo. If you want to continue using BlackFriday as the default for md/markdown extensions, you can use this configuration: ```toml [markup] defaultMarkdownHandler="blackfriday" ``` Fixes #5963 Fixes #1778 Fixes #6355
Diffstat (limited to 'markup/converter')
-rw-r--r--markup/converter/converter.go37
1 files changed, 30 insertions, 7 deletions
diff --git a/markup/converter/converter.go b/markup/converter/converter.go
index 809efca8e..a1141f65c 100644
--- a/markup/converter/converter.go
+++ b/markup/converter/converter.go
@@ -16,33 +16,51 @@ package converter
import (
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/config"
+ "github.com/gohugoio/hugo/markup/markup_config"
+ "github.com/gohugoio/hugo/markup/tableofcontents"
"github.com/spf13/afero"
)
// ProviderConfig configures a new Provider.
type ProviderConfig struct {
+ MarkupConfig markup_config.Config
+
Cfg config.Provider // Site config
ContentFs afero.Fs
Logger *loggers.Logger
Highlight func(code, lang, optsStr string) (string, error)
}
-// NewProvider creates converter providers.
-type NewProvider interface {
+// ProviderProvider creates converter providers.
+type ProviderProvider interface {
New(cfg ProviderConfig) (Provider, error)
}
// Provider creates converters.
type Provider interface {
New(ctx DocumentContext) (Converter, error)
+ Name() string
+}
+
+// NewProvider creates a new Provider with the given name.
+func NewProvider(name string, create func(ctx DocumentContext) (Converter, error)) Provider {
+ return newConverter{
+ name: name,
+ create: create,
+ }
+}
+
+type newConverter struct {
+ name string
+ create func(ctx DocumentContext) (Converter, error)
}
-// NewConverter is an adapter that can be used as a ConverterProvider.
-type NewConverter func(ctx DocumentContext) (Converter, error)
+func (n newConverter) New(ctx DocumentContext) (Converter, error) {
+ return n.create(ctx)
+}
-// New creates a new Converter for the given ctx.
-func (n NewConverter) New(ctx DocumentContext) (Converter, error) {
- return n(ctx)
+func (n newConverter) Name() string {
+ return n.name
}
// Converter wraps the Convert method that converts some markup into
@@ -61,6 +79,11 @@ type DocumentInfo interface {
AnchorSuffix() string
}
+// TableOfContentsProvider provides the content as a ToC structure.
+type TableOfContentsProvider interface {
+ TableOfContents() tableofcontents.Root
+}
+
// Bytes holds a byte slice and implements the Result interface.
type Bytes []byte