summaryrefslogtreecommitdiff
path: root/vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-10-25 00:47:47 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-10-25 00:47:47 +0200
commitc6cc0108ca7738023b45e0eeac0fa2390532dd93 (patch)
tree36890e6cd3091bbab8efbe686cc56f467f645bfd /vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go
parent0130404a1dc663d4aa68d780c9bcb23a4243e68d (diff)
downloadjbmafp-master.tar.gz
Added vendor lock on depsHEADmaster
Diffstat (limited to 'vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go')
-rw-r--r--vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go118
1 files changed, 118 insertions, 0 deletions
diff --git a/vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go b/vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go
new file mode 100644
index 0000000..e27f2fb
--- /dev/null
+++ b/vendor/github.com/mangoumbrella/goldmark-figure/ast/ast.go
@@ -0,0 +1,118 @@
+// Copyright 2023 The goldmark-figure authors
+//
+// Use of this source code is governed by an MIT-style
+// license that can be found in the LICENSE file or at
+// https://opensource.org/licenses/MIT.
+package ast
+
+import (
+ gast "github.com/yuin/goldmark/ast"
+ "github.com/yuin/goldmark/renderer"
+ "github.com/yuin/goldmark/util"
+)
+
+// KindFigure is a NodeKind of the Figure node.
+var KindFigure = gast.NewNodeKind("Figure")
+
+// A Figure struct represents a table of Markdown(GFM) text.
+type Figure struct {
+ gast.BaseBlock
+}
+
+// Kind implements Node.Kind.
+func (n *Figure) Kind() gast.NodeKind {
+ return KindFigure
+}
+
+// Dump implements Node.Dump
+func (n *Figure) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, func(level int) {
+ })
+}
+
+// NewFigure returns a new Table node.
+func NewFigure() *Figure {
+ return &Figure{}
+}
+
+// KindFigureImage is a NodeKind of the FigureImage node.
+var KindFigureImage = gast.NewNodeKind("FigureImage")
+
+// A FigureImage struct represents a table of Markdown(GFM) text.
+type FigureImage struct {
+ gast.BaseBlock
+}
+
+// Kind implements Node.Kind.
+func (n *FigureImage) Kind() gast.NodeKind {
+ return KindFigureImage
+}
+
+// Dump implements Node.Dump
+func (n *FigureImage) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, func(level int) {
+ })
+}
+
+// NewFigureImage returns a new Table node.
+func NewFigureImage() *FigureImage {
+ return &FigureImage{}
+}
+
+// KindFigureCaption is a NodeKind of the FigureCaption node.
+var KindFigureCaption = gast.NewNodeKind("FigureCaption")
+
+// A FigureCaption struct represents a table of Markdown(GFM) text.
+type FigureCaption struct {
+ gast.BaseBlock
+}
+
+// Kind implements Node.Kind.
+func (n *FigureCaption) Kind() gast.NodeKind {
+ return KindFigureCaption
+}
+
+// Dump implements Node.Dump
+func (n *FigureCaption) Dump(source []byte, level int) {
+ gast.DumpHelper(n, source, level, nil, func(level int) {
+ })
+}
+
+// NewFigureCaption returns a new Table node.
+func NewFigureCaption() *FigureCaption {
+ return &FigureCaption{}
+}
+
+// FigureHTMLRenderer is a renderer.NodeRenderer implementation that
+// renders Figure nodes.
+type FigureHTMLRenderer struct {
+}
+
+// NewFigureHTMLRenderer returns a new FigureHTMLRenderer.
+func NewFigureHTMLRenderer() renderer.NodeRenderer {
+ return &FigureHTMLRenderer{}
+}
+
+// RegisterFuncs implements renderer.NodeRenderer.RegisterFuncs.
+func (r *FigureHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
+ reg.Register(KindFigure, r.renderFigure)
+ reg.Register(KindFigureCaption, r.renderFigureCaption)
+}
+
+func (r *FigureHTMLRenderer) renderFigure(w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
+ if entering {
+ _, _ = w.WriteString("<figure>\n")
+ } else {
+ _, _ = w.WriteString("</figure>\n")
+ }
+ return gast.WalkContinue, nil
+}
+
+func (r *FigureHTMLRenderer) renderFigureCaption(w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
+ if entering {
+ _, _ = w.WriteString("<figcaption><p>")
+ } else {
+ _, _ = w.WriteString("</p></figcaption>\n")
+ }
+ return gast.WalkContinue, nil
+}