apply stroke and fill to markdown
This commit is contained in:
parent
d28aed6184
commit
1a3511d632
3 changed files with 16 additions and 2 deletions
|
|
@ -45,6 +45,8 @@ func applyStyles(shape *d2target.Shape, obj *d2graph.Object) {
|
|||
}
|
||||
if obj.Attributes.Style.Fill != nil {
|
||||
shape.Fill = obj.Attributes.Style.Fill.Value
|
||||
} else if obj.Attributes.Shape.Value == d2target.ShapeText {
|
||||
shape.Fill = "transparent"
|
||||
}
|
||||
if obj.Attributes.Style.Stroke != nil {
|
||||
shape.Stroke = obj.Attributes.Style.Stroke.Value
|
||||
|
|
|
|||
|
|
@ -397,7 +397,10 @@ func (obj *Object) GetFill(theme *d2themes.Theme) string {
|
|||
|
||||
func (obj *Object) GetStroke(theme *d2themes.Theme, dashGapSize interface{}) string {
|
||||
shape := obj.Attributes.Shape.Value
|
||||
if strings.EqualFold(shape, d2target.ShapeCode) || strings.EqualFold(shape, d2target.ShapeClass) || strings.EqualFold(shape, d2target.ShapeSQLTable) {
|
||||
if strings.EqualFold(shape, d2target.ShapeCode) ||
|
||||
strings.EqualFold(shape, d2target.ShapeClass) ||
|
||||
strings.EqualFold(shape, d2target.ShapeSQLTable) ||
|
||||
strings.EqualFold(shape, d2target.ShapeText) {
|
||||
return theme.Colors.Neutrals.N1
|
||||
}
|
||||
if dashGapSize != 0.0 {
|
||||
|
|
|
|||
|
|
@ -770,7 +770,16 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string,
|
|||
)
|
||||
// we need the self closing form in this svg/xhtml context
|
||||
render = strings.ReplaceAll(render, "<hr>", "<hr />")
|
||||
fmt.Fprintf(writer, `<div xmlns="http://www.w3.org/1999/xhtml" class="md">%v</div>`, render)
|
||||
|
||||
var mdStyle string
|
||||
if targetShape.Fill != "" {
|
||||
mdStyle = fmt.Sprintf("background-color:%s;", targetShape.Fill)
|
||||
}
|
||||
if targetShape.Stroke != "" {
|
||||
mdStyle += fmt.Sprintf("color:%s;", targetShape.Stroke)
|
||||
}
|
||||
|
||||
fmt.Fprintf(writer, `<div xmlns="http://www.w3.org/1999/xhtml" class="md" style="%s">%v</div>`, mdStyle, render)
|
||||
fmt.Fprint(writer, `</foreignObject></g>`)
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in a new issue