thephpleague / html-to-markdown

Convert HTML to Markdown with PHP
MIT License
1.77k stars 204 forks source link

Change private methods to protected #247

Closed metalinspired closed 8 months ago

metalinspired commented 8 months ago

Long story short, I needed to add some custom functionality for a project I'm working on but since some of the HtmlConverter methods are private I would have to needlessly duplicate these private methods.

colinodell commented 8 months ago

Thanks for the contribution!

I generally don't like exposing private functions, but I can see how making createDOMDocument protected would be useful. But I'm less convinced about the other two methods. Would you be able to share what you're trying to do with those other methods and why making them protected would help you?

metalinspired commented 8 months ago

I actually solved my problem by approaching it from a completely different angle. It is a legacy application and rich text editor it is using generates invalid nested lists. For example: <ul><li>foo</li><ul><li>bar</li></ul></ul> Instead of: <ul><li>foo<ul><li>bar</li></ul></li></ul> My original intent was to fix this within DOM but, as it turns out, nested list gets appended to root element because they are, well, invalid. This, in turn, was the reason why HtmlConverter was producing unexpected result. I'm not sure if there is any need for this PR so close it if you wish :)

colinodell commented 8 months ago

Ah okay, glad you were able to solve it!