gitea源码

block_node.go 912B

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