Merge pull request #1399 from alixander/recursive-texts
Texts() recursively
This commit is contained in:
commit
90297e1b42
2 changed files with 21 additions and 0 deletions
|
|
@ -1611,6 +1611,24 @@ func (g *Graph) Texts() []*d2target.MText {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, board := range g.Layers {
|
||||||
|
for _, t := range board.Texts() {
|
||||||
|
texts = appendTextDedup(texts, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, board := range g.Scenarios {
|
||||||
|
for _, t := range board.Texts() {
|
||||||
|
texts = appendTextDedup(texts, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, board := range g.Steps {
|
||||||
|
for _, t := range board.Texts() {
|
||||||
|
texts = appendTextDedup(texts, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return texts
|
return texts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package d2lib
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -20,6 +21,7 @@ import (
|
||||||
|
|
||||||
type CompileOptions struct {
|
type CompileOptions struct {
|
||||||
UTF16 bool
|
UTF16 bool
|
||||||
|
FS fs.FS
|
||||||
MeasuredTexts []*d2target.MText
|
MeasuredTexts []*d2target.MText
|
||||||
Ruler *textmeasure.Ruler
|
Ruler *textmeasure.Ruler
|
||||||
Layout func(context.Context, *d2graph.Graph) error
|
Layout func(context.Context, *d2graph.Graph) error
|
||||||
|
|
@ -42,6 +44,7 @@ func Compile(ctx context.Context, input string, opts *CompileOptions) (*d2target
|
||||||
|
|
||||||
g, err := d2compiler.Compile(opts.InputPath, strings.NewReader(input), &d2compiler.CompileOptions{
|
g, err := d2compiler.Compile(opts.InputPath, strings.NewReader(input), &d2compiler.CompileOptions{
|
||||||
UTF16: opts.UTF16,
|
UTF16: opts.UTF16,
|
||||||
|
FS: opts.FS,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue