mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 00:47:15 -04:00
Add StyleStack.Indent and .With
This commit is contained in:
@@ -70,12 +70,29 @@ func (s *StyleStack) Pop() {
|
|||||||
*s = stack
|
*s = stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s StyleStack) Indent() uint {
|
||||||
|
var i uint
|
||||||
|
|
||||||
|
for _, v := range s {
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
i += v.Indent
|
||||||
|
}
|
||||||
|
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
func (s StyleStack) Current() *ElementStyle {
|
func (s StyleStack) Current() *ElementStyle {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return s[len(s)-1]
|
return cascadeStyles(s[0:len(s)-1], s[len(s)-1])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s StyleStack) With(child *ElementStyle) *ElementStyle {
|
||||||
|
return cascadeStyles(s, child)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cascadeStyle(parent *ElementStyle, child *ElementStyle) *ElementStyle {
|
func cascadeStyle(parent *ElementStyle, child *ElementStyle) *ElementStyle {
|
||||||
|
|||||||
Reference in New Issue
Block a user