package mml
import "github.com/d2lang/mathjax-go/internal/ordered"
type Definition struct {
Defaults *ordered .Map [Property ]
Flags Flags
}
type Factory struct {
definitions map [string ]Definition
global *ordered .Map [Property ]
}
func NewFactory () *Factory {
return &Factory {
definitions : make (map [string ]Definition ),
global : ordered .New [Property ](),
}
}
func (f *Factory ) Globals () *ordered .Map [Property ] { return f .global }
func (f *Factory ) Register (kind string , definition Definition ) {
definition .Defaults = definition .Defaults .Clone ()
f .definitions [kind ] = definition
}
func (f *Factory ) Definition (kind string ) (Definition , bool ) {
definition , ok := f .definitions [kind ]
return definition , ok
}
func (f *Factory ) Create (kind string , children ...*Node ) *Node {
definition := f .definitions [kind ]
node := NewNode (kind , definition .Defaults , f .global , children ...)
node .Flags = definition .Flags
return node
}
func (f *Factory ) Text (text string ) *Node { return NewText (text ) }
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .