aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup/goldmark/links/transform.go
diff options
context:
space:
mode:
Diffstat (limited to 'markup/goldmark/links/transform.go')
-rw-r--r--markup/goldmark/links/transform.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/markup/goldmark/links/transform.go b/markup/goldmark/links/transform.go
deleted file mode 100644
index 2a7815b70..000000000
--- a/markup/goldmark/links/transform.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package images
-
-import (
- "github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/parser"
- "github.com/yuin/goldmark/text"
-)
-
-type (
- linksExtension struct {
- wrapStandAloneImageWithinParagraph bool
- }
-)
-
-const (
- // Used to signal to the rendering step that an image is used in a block context.
- // Dont's change this; the prefix must match the internalAttrPrefix in the root goldmark package.
- AttrIsBlock = "_h__isBlock"
-)
-
-type Transformer struct {
- wrapStandAloneImageWithinParagraph bool
-}
-
-// Transform transforms the provided Markdown AST.
-func (t *Transformer) Transform(doc *ast.Document, reader text.Reader, pctx parser.Context) {
- ast.Walk(doc, func(node ast.Node, enter bool) (ast.WalkStatus, error) {
- if !enter {
- return ast.WalkContinue, nil
- }
-
- if n, ok := node.(*ast.Image); ok {
- parent := n.Parent()
-
- if !t.wrapStandAloneImageWithinParagraph {
- isBlock := parent.ChildCount() == 1
- if isBlock {
- n.SetAttributeString(AttrIsBlock, true)
- }
-
- if isBlock && parent.Kind() == ast.KindParagraph {
- for _, attr := range parent.Attributes() {
- // Transfer any attribute set down to the image.
- // Image elements does not support attributes on its own,
- // so it's safe to just set without checking first.
- n.SetAttribute(attr.Name, attr.Value)
- }
- grandParent := parent.Parent()
- grandParent.ReplaceChild(grandParent, parent, n)
- }
- }
-
- }
-
- return ast.WalkContinue, nil
- })
-}