code.gitea.io/gitea@v1.19.3/modules/markup/markdown/math/inline_node.go (about) 1 // Copyright 2022 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package math 5 6 import ( 7 "github.com/yuin/goldmark/ast" 8 "github.com/yuin/goldmark/util" 9 ) 10 11 // Inline represents inline math e.g. $...$ or \(...\) 12 type Inline struct { 13 ast.BaseInline 14 } 15 16 // Inline implements Inline.Inline. 17 func (n *Inline) Inline() {} 18 19 // IsBlank returns if this inline node is empty 20 func (n *Inline) IsBlank(source []byte) bool { 21 for c := n.FirstChild(); c != nil; c = c.NextSibling() { 22 text := c.(*ast.Text).Segment 23 if !util.IsBlank(text.Value(source)) { 24 return false 25 } 26 } 27 return true 28 } 29 30 // Dump renders this inline math as debug 31 func (n *Inline) Dump(source []byte, level int) { 32 ast.DumpHelper(n, source, level, nil, nil) 33 } 34 35 // KindInline is the kind for math inline 36 var KindInline = ast.NewNodeKind("MathInline") 37 38 // Kind returns KindInline 39 func (n *Inline) Kind() ast.NodeKind { 40 return KindInline 41 } 42 43 // NewInline creates a new ast math inline node 44 func NewInline() *Inline { 45 return &Inline{ 46 BaseInline: ast.BaseInline{}, 47 } 48 }