ImportOptions selects caller-owned presentation context that is outside the
imported SVG subtree. A nil CurrentColor preserves SVG's opaque-black
initial color. ImportNodeWithOptions copies the pointed-to value before
parsing and never retains the pointer.CurrentColor*color.NRGBA
func ImportNodeWithOptions(ctx context.Context, source string, data []byte, limits Limits, options ImportOptions) (*Result, error)
PathLimits are caller-selected hard limits for one SVG path data string.
MaxCommands counts parsed source command groups, including groups such as an
identical-endpoint arc that SVG defines to emit no segment. Both values must
be positive.MaxBytesintMaxCommandsint
func ParsePath(ctx context.Context, source, data string, limits PathLimits) ([]d2scene.PathCommand, error)
ImportNode imports a strict SVG subset. It never reads files, resolves a
URL, or performs network I/O. On every error it returns a nil result.
Nested svg viewports are limited to finite absolute placement and dimensions
with an explicit viewBox. Paint servers other than bounded local user-space
linear gradients, clipping outside the bounded local user-space subset,
masking, general painted text, nested SVG images, and external references
are intentionally rejected rather than silently approximated. Embedded
images are restricted to canonical base64 data URIs containing one static
PNG, JPEG, GIF, or WebP resource. The sole painted
text exception is the exact U+00B5 fallback emitted by D2's frozen MathJax
renderer; it is converted to a pinned deterministic outline. Root ex lengths
are accepted only with MathJax's exact inert vertical-align form, where one
ex is deterministically eight CSS pixels.
Non-painting title and corpus-bounded editor metadata are ignored after
strict validation. Stylesheets are limited to a bounded simple
class-selector subset; see stylesheet.go.
ImportNodeWithOptions imports the same strict subset as ImportNode with an
explicit initial currentColor. An SVG color declaration still takes normal
cascade precedence over this caller-supplied value.
ParsePath converts the complete common SVG path grammar to absolute typed
d2scene commands. source must already be safe to include in an error (asset
resolvers should pass their redacted display name, never a credentialed URL).
The pages are generated with Goldsv0.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.