base64 encode d2 id, change from id to class name
This commit is contained in:
parent
9bc1b6ef20
commit
1c51657598
1 changed files with 3 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ package d2svg
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/fnv"
|
"hash/fnv"
|
||||||
|
|
@ -508,7 +509,7 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
|
||||||
if len(connection.Classes) > 0 {
|
if len(connection.Classes) > 0 {
|
||||||
classStr = fmt.Sprintf(` class="%s"`, strings.Join(connection.Classes, " "))
|
classStr = fmt.Sprintf(` class="%s"`, strings.Join(connection.Classes, " "))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(writer, `<g id="%s"%s%s>`, svg.EscapeText(connection.ID), opacityStyle, classStr)
|
fmt.Fprintf(writer, `<g class="%s"%s%s>`, base64.URLEncoding.EncodeToString([]byte(svg.EscapeText(connection.ID))), opacityStyle, classStr)
|
||||||
var markerStart string
|
var markerStart string
|
||||||
if connection.SrcArrow != d2target.NoArrowhead {
|
if connection.SrcArrow != d2target.NoArrowhead {
|
||||||
id := arrowheadMarkerID(false, connection)
|
id := arrowheadMarkerID(false, connection)
|
||||||
|
|
@ -984,7 +985,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
|
||||||
if len(targetShape.Classes) > 0 {
|
if len(targetShape.Classes) > 0 {
|
||||||
classStr = fmt.Sprintf(` class="%s"`, strings.Join(targetShape.Classes, " "))
|
classStr = fmt.Sprintf(` class="%s"`, strings.Join(targetShape.Classes, " "))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(writer, `<g id="%s"%s%s>`, svg.EscapeText(targetShape.ID), opacityStyle, classStr)
|
fmt.Fprintf(writer, `<g class="%s"%s%s>`, base64.URLEncoding.EncodeToString([]byte(svg.EscapeText(targetShape.ID))), opacityStyle, classStr)
|
||||||
tl := geo.NewPoint(float64(targetShape.Pos.X), float64(targetShape.Pos.Y))
|
tl := geo.NewPoint(float64(targetShape.Pos.X), float64(targetShape.Pos.Y))
|
||||||
width := float64(targetShape.Width)
|
width := float64(targetShape.Width)
|
||||||
height := float64(targetShape.Height)
|
height := float64(targetShape.Height)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue