-
Notifications
You must be signed in to change notification settings - Fork 5
V1.6 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
V1.6 #31
Changes from all commits
3a08fe0
5c58400
8c526f0
7003917
202c0b9
f93ed25
abf4ed4
d9d200d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
type AnchorAttribute struct { | ||||||||||||||||||||||||||||||||||||
attribute | ||||||||||||||||||||||||||||||||||||
child | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
ID Elements `json:"id"` | ||||||||||||||||||||||||||||||||||||
Label Elements | ||||||||||||||||||||||||||||||||||||
|
@@ -65,12 +66,16 @@ func (aa *AnchorAttribute) AsciiDocString() string { | |||||||||||||||||||||||||||||||||||
return sb.String() | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func (aa *AnchorAttribute) Traverse(parent Parent) iter.Seq2[Parent, Parent] { | ||||||||||||||||||||||||||||||||||||
return func(yield func(Parent, Parent) bool) { | ||||||||||||||||||||||||||||||||||||
if !yield(parent, &aa.Label) { | ||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
func (aa *AnchorAttribute) Append(el ...Element) { | ||||||||||||||||||||||||||||||||||||
aa.Label.Append(el...) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func (aa *AnchorAttribute) Children() Elements { | ||||||||||||||||||||||||||||||||||||
return aa.ID | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func (aa *AnchorAttribute) Clone() Attribute { | ||||||||||||||||||||||||||||||||||||
return &AnchorAttribute{attribute: aa.attribute, ID: aa.ID.Clone(), Label: aa.Label.Clone()} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
type Anchor struct { | ||||||||||||||||||||||||||||||||||||
|
@@ -103,6 +108,18 @@ func (a *Anchor) Equals(o Element) bool { | |||||||||||||||||||||||||||||||||||
return a.Elements.Equals(oa.Elements) | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func (a *Anchor) Clone() Element { | ||||||||||||||||||||||||||||||||||||
return &Anchor{position: a.position, ID: a.ID, Elements: a.Elements.Clone()} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func NewAnchor(id Elements, label Elements) *Anchor { | ||||||||||||||||||||||||||||||||||||
return &Anchor{ID: id, Elements: label} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
func (aa *Anchor) Traverse(parent Parent) iter.Seq2[Parent, Parent] { | ||||||||||||||||||||||||||||||||||||
return func(yield func(Parent, Parent) bool) { | ||||||||||||||||||||||||||||||||||||
if !yield(parent, &aa.ID) { | ||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+119
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,14 +33,21 @@ func (b *Bold) Equals(e Element) bool { | |||||||||||||
return b.Elements.Equals(ob.Elements) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (b *Bold) Traverse(parent Parent) iter.Seq2[Parent, Parent] { | ||||||||||||||
return func(yield func(Parent, Parent) bool) { | ||||||||||||||
func (b *Bold) Traverse(parent ParentElement) iter.Seq2[ParentElement, Parent] { | ||||||||||||||
return func(yield func(ParentElement, Parent) bool) { | ||||||||||||||
if !b.AttributeList.traverse(b, yield) { | ||||||||||||||
return | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
var _ ParentElement = &Bold{} | ||||||||||||||
var _ Traverser = &Bold{} | ||||||||||||||
|
||||||||||||||
func (b *Bold) Clone() Element { | ||||||||||||||
return &Bold{position: b.position, raw: b.raw, AttributeList: b.AttributeList.Clone(), Elements: b.Elements.Clone()} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
type DoubleBold struct { | ||||||||||||||
position | ||||||||||||||
raw | ||||||||||||||
|
@@ -72,10 +79,17 @@ func (db *DoubleBold) Equals(e Element) bool { | |||||||||||||
return db.Elements.Equals(ob.Elements) | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (db *DoubleBold) Traverse(parent Parent) iter.Seq2[Parent, Parent] { | ||||||||||||||
return func(yield func(Parent, Parent) bool) { | ||||||||||||||
func (db *DoubleBold) Traverse(parent ParentElement) iter.Seq2[ParentElement, Parent] { | ||||||||||||||
return func(yield func(ParentElement, Parent) bool) { | ||||||||||||||
if !db.AttributeList.traverse(db, yield) { | ||||||||||||||
return | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (db *DoubleBold) Clone() Element { | ||||||||||||||
return &Bold{position: db.position, raw: db.raw, AttributeList: db.AttributeList.Clone(), Elements: db.Elements.Clone()} | ||||||||||||||
} | ||||||||||||||
Comment on lines
+90
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||
|
||||||||||||||
var _ ParentElement = &DoubleBold{} | ||||||||||||||
var _ Traverser = &DoubleBold{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Children()
method returnsaa.ID
, while theAppend()
method modifiesaa.Label
. This is inconsistent. TheParent
interface, whichChildren()
is part of, implies thatChildren()
should return the elements that can be modified byAppend()
. To maintain consistency,Children()
should probably returnaa.Label
.