Skip to content

Conversation

@ilian2233
Copy link

@ilian2233 ilian2233 requested review from a team as code owners November 22, 2025 12:43
Copy link

@vlasakievft vlasakievft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Maybe would be a good idea to add tests for:

	InNumbers
	Recommended
	RecommendedList

@krasimirakirilova
Copy link

praise: The commits are organized in a very good way!
suggestion: The last two commits can be removed.

)
var ErrUnknownKind = errors.New("unknown tree kind")

var toSeparate = []string{contenttree.HeadingType, contenttree.ParagraphType}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it logical to add contenttree.PullquoteType to toSeparate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This wouldn't have solved the problem, but I revamped the spacing logic and should be ok now.


return pq.Text, nil
case contenttree.InNumbersType:
def, ok := n.(*contenttree.Definition)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Here the node should be typecast to contenttree.InNumber and the title field on it should be used.

in, ok := n.(*contenttree.InNumbers)
if !ok {
         return "", errors.New("failed to parse node to InNumbers")
}
 resultChildred, err := transformChildren(in.GetChildren())
if err != nil {
     return "", err
}
return fmt.Sprintf("%s %s", in.Title, resultChildred), nil

Then, we will need an additional case for Definition type.

return transformNode(root.Body)
}

switch n.GetType() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we should add case: contenttree.TimelineEventChildType node for completeness.

The code works without it because in the default case we are calling n.GetChildren() which internally calls the GetChildren on the embedded node. For example,

func (n *TimelineEventChild) GetChildren() []Node {
     if n.Paragraph != nil {
        return n.Paragraph.GetChildren()
     }
    if n.ImageSet != nil {
       return n.ImageSet.GetChildren()
    }
    return nil
}

So theoretically, we could get rid of all the checks where we return transformNode(n.GetEmbedded()).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing the transformNode(n.GetEmbedded()) would be the better approach here.
No need to burden the switch with more cases than needed. What do you think @todor-videv1?

Copy link

@todor-videv1 todor-videv1 Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two options here... if we are sure we can safely remove the n.GetEmbedded()... less is more, I'd advse to leave a comment in the code how the default case is dealing with these embeds though.

If we have even an ounce of doubt, add the additional case like Lokender suggests, and then when we fix the tests, we can do this enhancement.

@tsvetko24 tsvetko24 requested review from a team, lokendersinghft and vlasakievft November 25, 2025 19:49
@ilian2233 ilian2233 force-pushed the feature/UPPSF-6584-extend-the-to-string-transformer branch from 6e308e3 to cef1a0b Compare November 27, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants