embed d2 version in svg

This commit is contained in:
Alexander Wang 2023-03-11 08:34:31 -08:00
parent e656cf75d1
commit 2f2056da2a
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
2 changed files with 4 additions and 2 deletions

View file

@ -35,6 +35,7 @@ import (
"oss.terrastruct.com/d2/lib/shape"
"oss.terrastruct.com/d2/lib/svg"
"oss.terrastruct.com/d2/lib/textmeasure"
"oss.terrastruct.com/d2/lib/version"
)
const (
@ -1779,8 +1780,9 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
dimensions = fmt.Sprintf(` width="%d" height="%d"`, w, h)
}
fitToScreenWrapper := fmt.Sprintf(`<svg %s preserveAspectRatio="xMinYMin meet" viewBox="0 0 %d %d"%s>`,
fitToScreenWrapper := fmt.Sprintf(`<svg %s d2:version="%s" preserveAspectRatio="xMinYMin meet" viewBox="0 0 %d %d"%s>`,
`xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"`,
version.Version,
w, h,
dimensions,
)

View file

@ -1,4 +1,4 @@
package version
// Pre-built binaries will have version set correctly during build time.
var Version = "v0.2.2-HEAD"
var Version = "v0.2.4-HEAD"