diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-03-17 11:12:33 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-05-14 13:12:08 +0200 |
commit | e2d66e3218e180bbfca06ca3a29ce01957c513e9 (patch) | |
tree | ed29bb99cf16b75b6334e2fc618d31e80203e5d5 /markup/markup.go | |
parent | 55dea41c1ab703f13b841389c6888815a033cf86 (diff) | |
download | hugo-e2d66e3218e180bbfca06ca3a29ce01957c513e9.tar.gz hugo-e2d66e3218e180bbfca06ca3a29ce01957c513e9.zip |
Create pages from _content.gotmpl
Closes #12427
Closes #12485
Closes #6310
Closes #5074
Diffstat (limited to 'markup/markup.go')
-rw-r--r-- | markup/markup.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/markup/markup.go b/markup/markup.go index 835c7bbec..cd1c1f823 100644 --- a/markup/markup.go +++ b/markup/markup.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/gohugoio/hugo/markup/highlight" + "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/markup/markup_config" @@ -44,7 +45,7 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro defaultHandler := mcfg.DefaultMarkdownHandler var defaultFound bool - add := func(p converter.ProviderProvider, aliases ...string) error { + add := func(p converter.ProviderProvider, subType string, aliases ...string) error { c, err := p.New(cfg) if err != nil { return err @@ -53,6 +54,7 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro name := c.Name() aliases = append(aliases, name) + aliases = append(aliases, subType) if strings.EqualFold(name, defaultHandler) { aliases = append(aliases, "markdown") @@ -63,19 +65,21 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro return nil } - if err := add(goldmark.Provider); err != nil { + contentTypes := cfg.Conf.ContentTypes().(media.ContentTypes) + + if err := add(goldmark.Provider, contentTypes.Markdown.SubType, contentTypes.Markdown.Suffixes()...); err != nil { return nil, err } - if err := add(asciidocext.Provider, "ad", "adoc"); err != nil { + if err := add(asciidocext.Provider, contentTypes.AsciiDoc.SubType, contentTypes.AsciiDoc.Suffixes()...); err != nil { return nil, err } - if err := add(rst.Provider); err != nil { + if err := add(rst.Provider, contentTypes.ReStructuredText.SubType, contentTypes.ReStructuredText.Suffixes()...); err != nil { return nil, err } - if err := add(pandoc.Provider, "pdc"); err != nil { + if err := add(pandoc.Provider, contentTypes.Pandoc.SubType, contentTypes.Pandoc.Suffixes()...); err != nil { return nil, err } - if err := add(org.Provider); err != nil { + if err := add(org.Provider, contentTypes.EmacsOrgMode.SubType, contentTypes.EmacsOrgMode.Suffixes()...); err != nil { return nil, err } @@ -133,3 +137,16 @@ func addConverter(m map[string]converter.Provider, c converter.Provider, aliases m[alias] = c } } + +// ResolveMarkup returns the markup type. +func ResolveMarkup(s string) string { + s = strings.ToLower(s) + switch s { + case "goldmark": + return media.DefaultContentTypes.Markdown.SubType + case "asciidocext": + return media.DefaultContentTypes.AsciiDoc.SubType + default: + return s + } +} |