2019-11-06 19:10:47 +00:00
|
|
|
// Copyright 2019 The Hugo Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
// Package goldmark converts Markdown to HTML using Goldmark.
|
|
|
|
package goldmark
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2024-05-04 01:06:10 +00:00
|
|
|
"github.com/gohugoio/hugo-goldmark-extensions/extras"
|
2024-01-06 16:53:24 +00:00
|
|
|
"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
|
2024-04-11 15:46:18 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/hugocontext"
|
2023-12-05 23:29:03 +00:00
|
|
|
"github.com/yuin/goldmark/util"
|
|
|
|
|
2022-02-17 12:04:00 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/codeblocks"
|
2023-04-12 08:15:02 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
|
2022-12-03 11:33:48 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/images"
|
2021-02-07 17:08:46 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/internal/extensions/attributes"
|
2022-02-17 12:04:00 +00:00
|
|
|
"github.com/gohugoio/hugo/markup/goldmark/internal/render"
|
2021-02-07 17:08:46 +00:00
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
"github.com/yuin/goldmark"
|
2023-10-24 10:04:13 +00:00
|
|
|
emoji "github.com/yuin/goldmark-emoji"
|
2023-02-24 06:23:10 +00:00
|
|
|
"github.com/yuin/goldmark/ast"
|
2019-11-06 19:10:47 +00:00
|
|
|
"github.com/yuin/goldmark/extension"
|
|
|
|
"github.com/yuin/goldmark/parser"
|
|
|
|
"github.com/yuin/goldmark/renderer"
|
|
|
|
"github.com/yuin/goldmark/renderer/html"
|
|
|
|
"github.com/yuin/goldmark/text"
|
2023-12-05 23:29:03 +00:00
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/markup/converter"
|
|
|
|
"github.com/gohugoio/hugo/markup/tableofcontents"
|
2019-11-06 19:10:47 +00:00
|
|
|
)
|
|
|
|
|
2022-12-03 11:33:48 +00:00
|
|
|
const (
|
|
|
|
internalAttrPrefix = "_h__"
|
|
|
|
)
|
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
// Provider is the package entry point.
|
|
|
|
var Provider converter.ProviderProvider = provide{}
|
|
|
|
|
2022-02-16 12:44:09 +00:00
|
|
|
type provide struct{}
|
2019-11-06 19:10:47 +00:00
|
|
|
|
|
|
|
func (p provide) New(cfg converter.ProviderConfig) (converter.Provider, error) {
|
2019-11-27 12:42:36 +00:00
|
|
|
md := newMarkdown(cfg)
|
2020-01-04 10:28:19 +00:00
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
return converter.NewProvider("goldmark", func(ctx converter.DocumentContext) (converter.Converter, error) {
|
|
|
|
return &goldmarkConverter{
|
|
|
|
ctx: ctx,
|
|
|
|
cfg: cfg,
|
|
|
|
md: md,
|
2020-01-04 10:28:19 +00:00
|
|
|
sanitizeAnchorName: func(s string) string {
|
2023-01-04 17:24:36 +00:00
|
|
|
return sanitizeAnchorNameString(s, cfg.MarkupConfig().Goldmark.Parser.AutoHeadingIDType)
|
2020-01-04 10:28:19 +00:00
|
|
|
},
|
2019-11-06 19:10:47 +00:00
|
|
|
}, nil
|
|
|
|
}), nil
|
|
|
|
}
|
|
|
|
|
2020-12-02 12:23:25 +00:00
|
|
|
var _ converter.AnchorNameSanitizer = (*goldmarkConverter)(nil)
|
2020-01-04 10:28:19 +00:00
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
type goldmarkConverter struct {
|
|
|
|
md goldmark.Markdown
|
|
|
|
ctx converter.DocumentContext
|
|
|
|
cfg converter.ProviderConfig
|
2020-01-04 10:28:19 +00:00
|
|
|
|
|
|
|
sanitizeAnchorName func(s string) string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *goldmarkConverter) SanitizeAnchorName(s string) string {
|
|
|
|
return c.sanitizeAnchorName(s)
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
|
|
|
|
2019-11-27 12:42:36 +00:00
|
|
|
func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
|
2023-01-04 17:24:36 +00:00
|
|
|
mcfg := pcfg.MarkupConfig()
|
|
|
|
cfg := mcfg.Goldmark
|
2020-02-22 17:06:30 +00:00
|
|
|
var rendererOptions []renderer.Option
|
2019-11-06 19:10:47 +00:00
|
|
|
|
|
|
|
if cfg.Renderer.HardWraps {
|
|
|
|
rendererOptions = append(rendererOptions, html.WithHardWraps())
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Renderer.XHTML {
|
|
|
|
rendererOptions = append(rendererOptions, html.WithXHTML())
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Renderer.Unsafe {
|
|
|
|
rendererOptions = append(rendererOptions, html.WithUnsafe())
|
|
|
|
}
|
|
|
|
|
2023-12-05 23:29:03 +00:00
|
|
|
tocRendererOptions := make([]renderer.Option, len(rendererOptions))
|
|
|
|
if rendererOptions != nil {
|
|
|
|
copy(tocRendererOptions, rendererOptions)
|
|
|
|
}
|
|
|
|
tocRendererOptions = append(tocRendererOptions,
|
|
|
|
renderer.WithNodeRenderers(util.Prioritized(extension.NewStrikethroughHTMLRenderer(), 500)),
|
|
|
|
renderer.WithNodeRenderers(util.Prioritized(emoji.NewHTMLRenderer(), 200)))
|
2020-02-22 17:06:30 +00:00
|
|
|
var (
|
|
|
|
extensions = []goldmark.Extender{
|
2024-04-11 15:46:18 +00:00
|
|
|
hugocontext.New(),
|
2022-03-09 17:26:32 +00:00
|
|
|
newLinks(cfg),
|
2023-12-05 23:29:03 +00:00
|
|
|
newTocExtension(tocRendererOptions),
|
2020-02-22 17:06:30 +00:00
|
|
|
}
|
|
|
|
parserOptions []parser.Option
|
|
|
|
)
|
|
|
|
|
2022-12-03 11:33:48 +00:00
|
|
|
extensions = append(extensions, images.New(cfg.Parser.WrapStandAloneImageWithinParagraph))
|
|
|
|
|
2024-05-04 01:06:10 +00:00
|
|
|
extensions = append(extensions, extras.New(
|
|
|
|
extras.Config{
|
2024-06-15 13:45:27 +00:00
|
|
|
Delete: extras.DeleteConfig{Enable: cfg.Extensions.Extras.Delete.Enable},
|
2024-05-04 01:06:10 +00:00
|
|
|
Insert: extras.InsertConfig{Enable: cfg.Extensions.Extras.Insert.Enable},
|
|
|
|
Mark: extras.MarkConfig{Enable: cfg.Extensions.Extras.Mark.Enable},
|
|
|
|
Subscript: extras.SubscriptConfig{Enable: cfg.Extensions.Extras.Subscript.Enable},
|
|
|
|
Superscript: extras.SuperscriptConfig{Enable: cfg.Extensions.Extras.Superscript.Enable},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
if mcfg.Highlight.CodeFences {
|
2022-02-17 12:04:00 +00:00
|
|
|
extensions = append(extensions, codeblocks.New())
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.Table {
|
|
|
|
extensions = append(extensions, extension.Table)
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.Strikethrough {
|
|
|
|
extensions = append(extensions, extension.Strikethrough)
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.Linkify {
|
|
|
|
extensions = append(extensions, extension.Linkify)
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.TaskList {
|
|
|
|
extensions = append(extensions, extension.TaskList)
|
|
|
|
}
|
|
|
|
|
2023-04-12 08:15:02 +00:00
|
|
|
if !cfg.Extensions.Typographer.Disable {
|
|
|
|
t := extension.NewTypographer(
|
|
|
|
extension.WithTypographicSubstitutions(toTypographicPunctuationMap(cfg.Extensions.Typographer)),
|
|
|
|
)
|
|
|
|
extensions = append(extensions, t)
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.DefinitionList {
|
|
|
|
extensions = append(extensions, extension.DefinitionList)
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.Footnote {
|
|
|
|
extensions = append(extensions, extension.Footnote)
|
|
|
|
}
|
|
|
|
|
2023-08-30 11:08:45 +00:00
|
|
|
if cfg.Extensions.CJK.Enable {
|
|
|
|
opts := []extension.CJKOption{}
|
|
|
|
if cfg.Extensions.CJK.EastAsianLineBreaks {
|
2023-10-29 09:13:56 +00:00
|
|
|
if cfg.Extensions.CJK.EastAsianLineBreaksStyle == "css3draft" {
|
|
|
|
opts = append(opts, extension.WithEastAsianLineBreaks(extension.EastAsianLineBreaksCSS3Draft))
|
|
|
|
} else {
|
|
|
|
opts = append(opts, extension.WithEastAsianLineBreaks())
|
|
|
|
}
|
2023-08-30 11:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.Extensions.CJK.EscapedSpace {
|
|
|
|
opts = append(opts, extension.WithEscapedSpace())
|
|
|
|
}
|
|
|
|
c := extension.NewCJK(opts...)
|
|
|
|
extensions = append(extensions, c)
|
|
|
|
}
|
|
|
|
|
2024-01-06 16:53:24 +00:00
|
|
|
if cfg.Extensions.Passthrough.Enable {
|
|
|
|
configuredInlines := cfg.Extensions.Passthrough.Delimiters.Inline
|
|
|
|
configuredBlocks := cfg.Extensions.Passthrough.Delimiters.Block
|
|
|
|
|
|
|
|
inlineDelimiters := make([]passthrough.Delimiters, len(configuredInlines))
|
|
|
|
blockDelimiters := make([]passthrough.Delimiters, len(configuredBlocks))
|
|
|
|
|
|
|
|
for i, d := range configuredInlines {
|
|
|
|
inlineDelimiters[i] = passthrough.Delimiters{
|
|
|
|
Open: d[0],
|
|
|
|
Close: d[1],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for i, d := range configuredBlocks {
|
|
|
|
blockDelimiters[i] = passthrough.Delimiters{
|
|
|
|
Open: d[0],
|
|
|
|
Close: d[1],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-15 16:03:09 +00:00
|
|
|
extensions = append(extensions, passthrough.New(
|
|
|
|
passthrough.Config{
|
|
|
|
InlineDelimiters: inlineDelimiters,
|
|
|
|
BlockDelimiters: blockDelimiters,
|
|
|
|
},
|
2024-01-06 16:53:24 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2023-10-24 10:04:13 +00:00
|
|
|
if pcfg.Conf.EnableEmoji() {
|
|
|
|
extensions = append(extensions, emoji.Emoji)
|
|
|
|
}
|
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
if cfg.Parser.AutoHeadingID {
|
|
|
|
parserOptions = append(parserOptions, parser.WithAutoHeadingID())
|
|
|
|
}
|
|
|
|
|
2021-02-07 17:08:46 +00:00
|
|
|
if cfg.Parser.Attribute.Title {
|
2019-11-06 19:10:47 +00:00
|
|
|
parserOptions = append(parserOptions, parser.WithAttribute())
|
|
|
|
}
|
2023-10-24 10:04:13 +00:00
|
|
|
|
2021-02-07 17:08:46 +00:00
|
|
|
if cfg.Parser.Attribute.Block {
|
|
|
|
extensions = append(extensions, attributes.New())
|
|
|
|
}
|
|
|
|
|
2019-11-06 19:10:47 +00:00
|
|
|
md := goldmark.New(
|
|
|
|
goldmark.WithExtensions(
|
|
|
|
extensions...,
|
|
|
|
),
|
|
|
|
goldmark.WithParserOptions(
|
|
|
|
parserOptions...,
|
|
|
|
),
|
|
|
|
goldmark.WithRendererOptions(
|
|
|
|
rendererOptions...,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
return md
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
type parserResult struct {
|
|
|
|
doc any
|
2023-02-11 15:20:24 +00:00
|
|
|
toc *tableofcontents.Fragments
|
2023-02-24 06:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p parserResult) Doc() any {
|
|
|
|
return p.doc
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p parserResult) TableOfContents() *tableofcontents.Fragments {
|
|
|
|
return p.toc
|
|
|
|
}
|
|
|
|
|
|
|
|
type renderResult struct {
|
|
|
|
converter.ResultRender
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
type converterResult struct {
|
|
|
|
converter.ResultRender
|
|
|
|
tableOfContentsProvider
|
2019-11-27 12:42:36 +00:00
|
|
|
}
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
type tableOfContentsProvider interface {
|
|
|
|
TableOfContents() *tableofcontents.Fragments
|
|
|
|
}
|
2019-11-27 12:42:36 +00:00
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
func (c *goldmarkConverter) Parse(ctx converter.RenderContext) (converter.ResultParse, error) {
|
2020-01-04 10:28:19 +00:00
|
|
|
pctx := c.newParserContext(ctx)
|
2019-11-06 19:10:47 +00:00
|
|
|
reader := text.NewReader(ctx.Src)
|
|
|
|
|
|
|
|
doc := c.md.Parser().Parse(
|
|
|
|
reader,
|
|
|
|
parser.WithContext(pctx),
|
|
|
|
)
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
return parserResult{
|
|
|
|
doc: doc,
|
|
|
|
toc: pctx.TableOfContents(),
|
|
|
|
}, nil
|
|
|
|
}
|
all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning
There are some breaking changes in this commit, see #11455.
Closes #11455
Closes #11549
This fixes a set of bugs (see issue list) and it is also paying some technical debt accumulated over the years. We now build with Staticcheck enabled in the CI build.
The performance should be about the same as before for regular sized Hugo sites, but it should perform and scale much better to larger data sets, as objects that uses lots of memory (e.g. rendered Markdown, big JSON files read into maps with transform.Unmarshal etc.) will now get automatically garbage collected if needed. Performance on partial rebuilds when running the server in fast render mode should be the same, but the change detection should be much more accurate.
A list of the notable new features:
* A new dependency tracker that covers (almost) all of Hugo's API and is used to do fine grained partial rebuilds when running the server.
* A new and simpler tree document store which allows fast lookups and prefix-walking in all dimensions (e.g. language) concurrently.
* You can now configure an upper memory limit allowing for much larger data sets and/or running on lower specced PCs.
We have lifted the "no resources in sub folders" restriction for branch bundles (e.g. sections).
Memory Limit
* Hugos will, by default, set aside a quarter of the total system memory, but you can set this via the OS environment variable HUGO_MEMORYLIMIT (in gigabytes). This is backed by a partitioned LRU cache used throughout Hugo. A cache that gets dynamically resized in low memory situations, allowing Go's Garbage Collector to free the memory.
New Dependency Tracker: Hugo has had a rule based coarse grained approach to server rebuilds that has worked mostly pretty well, but there have been some surprises (e.g. stale content). This is now revamped with a new dependency tracker that can quickly calculate the delta given a changed resource (e.g. a content file, template, JS file etc.). This handles transitive relations, e.g. $page -> js.Build -> JS import, or $page1.Content -> render hook -> site.GetPage -> $page2.Title, or $page1.Content -> shortcode -> partial -> site.RegularPages -> $page2.Content -> shortcode ..., and should also handle changes to aggregated values (e.g. site.Lastmod) effectively.
This covers all of Hugo's API with 2 known exceptions (a list that may not be fully exhaustive):
Changes to files loaded with template func os.ReadFile may not be handled correctly. We recommend loading resources with resources.Get
Changes to Hugo objects (e.g. Page) passed in the template context to lang.Translate may not be detected correctly. We recommend having simple i18n templates without too much data context passed in other than simple types such as strings and numbers.
Note that the cachebuster configuration (when A changes then rebuild B) works well with the above, but we recommend that you revise that configuration, as it in most situations should not be needed. One example where it is still needed is with TailwindCSS and using changes to hugo_stats.json to trigger new CSS rebuilds.
Document Store: Previously, a little simplified, we split the document store (where we store pages and resources) in a tree per language. This worked pretty well, but the structure made some operations harder than they needed to be. We have now restructured it into one Radix tree for all languages. Internally the language is considered to be a dimension of that tree, and the tree can be viewed in all dimensions concurrently. This makes some operations re. language simpler (e.g. finding translations is just a slice range), but the idea is that it should also be relatively inexpensive to add more dimensions if needed (e.g. role).
Fixes #10169
Fixes #10364
Fixes #10482
Fixes #10630
Fixes #10656
Fixes #10694
Fixes #10918
Fixes #11262
Fixes #11439
Fixes #11453
Fixes #11457
Fixes #11466
Fixes #11540
Fixes #11551
Fixes #11556
Fixes #11654
Fixes #11661
Fixes #11663
Fixes #11664
Fixes #11669
Fixes #11671
Fixes #11807
Fixes #11808
Fixes #11809
Fixes #11815
Fixes #11840
Fixes #11853
Fixes #11860
Fixes #11883
Fixes #11904
Fixes #7388
Fixes #7425
Fixes #7436
Fixes #7544
Fixes #7882
Fixes #7960
Fixes #8255
Fixes #8307
Fixes #8863
Fixes #8927
Fixes #9192
Fixes #9324
2023-12-24 18:11:05 +00:00
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
func (c *goldmarkConverter) Render(ctx converter.RenderContext, doc any) (converter.ResultRender, error) {
|
|
|
|
n := doc.(ast.Node)
|
|
|
|
buf := &render.BufWriter{Buffer: &bytes.Buffer{}}
|
|
|
|
|
2022-02-17 12:04:00 +00:00
|
|
|
rcx := &render.RenderContextDataHolder{
|
|
|
|
Rctx: ctx,
|
|
|
|
Dctx: c.ctx,
|
2019-11-27 12:42:36 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 12:04:00 +00:00
|
|
|
w := &render.Context{
|
|
|
|
BufWriter: buf,
|
|
|
|
ContextData: rcx,
|
2019-11-27 12:42:36 +00:00
|
|
|
}
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
if err := c.md.Renderer().Render(w, ctx.Src, n); err != nil {
|
2019-11-06 19:10:47 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-02-24 06:23:10 +00:00
|
|
|
return renderResult{
|
|
|
|
ResultRender: buf,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *goldmarkConverter) Convert(ctx converter.RenderContext) (converter.ResultRender, error) {
|
|
|
|
parseResult, err := c.Parse(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
renderResult, err := c.Render(ctx, parseResult.Doc())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-11-27 12:42:36 +00:00
|
|
|
return converterResult{
|
2023-02-24 06:23:10 +00:00
|
|
|
ResultRender: renderResult,
|
|
|
|
tableOfContentsProvider: parseResult,
|
2019-11-27 12:42:36 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-01-04 10:28:19 +00:00
|
|
|
func (c *goldmarkConverter) newParserContext(rctx converter.RenderContext) *parserContext {
|
2023-01-04 17:24:36 +00:00
|
|
|
ctx := parser.NewContext(parser.WithIDs(newIDFactory(c.cfg.MarkupConfig().Goldmark.Parser.AutoHeadingIDType)))
|
2019-11-27 12:42:36 +00:00
|
|
|
ctx.Set(tocEnableKey, rctx.RenderTOC)
|
|
|
|
return &parserContext{
|
|
|
|
Context: ctx,
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
2019-11-27 12:42:36 +00:00
|
|
|
}
|
2019-11-06 19:10:47 +00:00
|
|
|
|
2019-11-27 12:42:36 +00:00
|
|
|
type parserContext struct {
|
|
|
|
parser.Context
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-11 15:20:24 +00:00
|
|
|
func (p *parserContext) TableOfContents() *tableofcontents.Fragments {
|
2019-11-27 12:42:36 +00:00
|
|
|
if v := p.Get(tocResultKey); v != nil {
|
2023-02-11 15:20:24 +00:00
|
|
|
return v.(*tableofcontents.Fragments)
|
2019-11-06 19:10:47 +00:00
|
|
|
}
|
2023-02-11 15:20:24 +00:00
|
|
|
return nil
|
2019-11-27 12:42:36 +00:00
|
|
|
}
|
2023-04-12 08:15:02 +00:00
|
|
|
|
|
|
|
// Note: It's tempting to put this in the config package, but that doesn't work.
|
|
|
|
// TODO(bep) create upstream issue.
|
|
|
|
func toTypographicPunctuationMap(t goldmark_config.Typographer) map[extension.TypographicPunctuation][]byte {
|
|
|
|
return map[extension.TypographicPunctuation][]byte{
|
|
|
|
extension.LeftSingleQuote: []byte(t.LeftSingleQuote),
|
|
|
|
extension.RightSingleQuote: []byte(t.RightSingleQuote),
|
|
|
|
extension.LeftDoubleQuote: []byte(t.LeftDoubleQuote),
|
|
|
|
extension.RightDoubleQuote: []byte(t.RightDoubleQuote),
|
|
|
|
extension.EnDash: []byte(t.EnDash),
|
|
|
|
extension.EmDash: []byte(t.EmDash),
|
|
|
|
extension.Ellipsis: []byte(t.Ellipsis),
|
|
|
|
extension.LeftAngleQuote: []byte(t.LeftAngleQuote),
|
|
|
|
extension.RightAngleQuote: []byte(t.RightAngleQuote),
|
|
|
|
extension.Apostrophe: []byte(t.Apostrophe),
|
|
|
|
}
|
|
|
|
}
|