code.gitea.io/gitea@v1.19.3/modules/markup/markdown/math/block_node.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package math
     5  
     6  import "github.com/yuin/goldmark/ast"
     7  
     8  // Block represents a display math block e.g. $$...$$ or \[...\]
     9  type Block struct {
    10  	ast.BaseBlock
    11  	Dollars bool
    12  	Indent  int
    13  	Closed  bool
    14  }
    15  
    16  // KindBlock is the node kind for math blocks
    17  var KindBlock = ast.NewNodeKind("MathBlock")
    18  
    19  // NewBlock creates a new math Block
    20  func NewBlock(dollars bool, indent int) *Block {
    21  	return &Block{
    22  		Dollars: dollars,
    23  		Indent:  indent,
    24  	}
    25  }
    26  
    27  // Dump dumps the block to a string
    28  func (n *Block) Dump(source []byte, level int) {
    29  	m := map[string]string{}
    30  	ast.DumpHelper(n, source, level, m, nil)
    31  }
    32  
    33  // Kind returns KindBlock for math Blocks
    34  func (n *Block) Kind() ast.NodeKind {
    35  	return KindBlock
    36  }
    37  
    38  // IsRaw returns true as this block should not be processed further
    39  func (n *Block) IsRaw() bool {
    40  	return true
    41  }