loading up the forgejo repo on tangled to test page performance
at forgejo 48 lines 1.1 kB view raw
1// Copyright 2022 The Gitea Authors. All rights reserved. 2// SPDX-License-Identifier: MIT 3 4package math 5 6import ( 7 "github.com/yuin/goldmark/ast" 8 "github.com/yuin/goldmark/util" 9) 10 11// Inline represents inline math e.g. $...$ or \(...\) 12type Inline struct { 13 ast.BaseInline 14} 15 16// Inline implements Inline.Inline. 17func (n *Inline) Inline() {} 18 19// IsBlank returns if this inline node is empty 20func (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 31func (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 36var KindInline = ast.NewNodeKind("MathInline") 37 38// Kind returns KindInline 39func (n *Inline) Kind() ast.NodeKind { 40 return KindInline 41} 42 43// NewInline creates a new ast math inline node 44func NewInline() *Inline { 45 return &Inline{ 46 BaseInline: ast.BaseInline{}, 47 } 48}