You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add generalized support for specifying Beautiful Soup options #223
But as shown above, the BeautifulSoup constructor provides other options that might be useful, such as providing hints to the text encoding detection for the HTML document.
Before #206 ships in a production release, perhaps we could extend its implementation to generally support all Beautiful Soup configuration options using a kwargs-based approach (including new options in the future). For example,
I like this! Maybe the shorter option name is preferable. One other method could be handing a bs4 instance directly, e.g. if one already has one configured to their liking. But I prefer your approach.
I don't think passing a BeautifulSoup object would work, as the HTML to parse is passed as part of the constructor. And for users working directly with BeautifulSoup objects (as our application does), they can simply call convert_soup() as described here.
I started working on a pull request to implement a kwargs-based solution, but I ran into a problem - there is no standard way to pass a dict as an argument value in the shell wrapper script:
Perhaps this is a sign to keep the current parser-only option, and if users have more complex needs, they can create their own BeautifulSoup objects and call convert_soup().
Activity
chrispy-snps commentedon May 28, 2025
@AlexVonB - if you're open to this, I'll submit a pull request.
AlexVonB commentedon May 28, 2025
I like this! Maybe the shorter option name is preferable. One other method could be handing a bs4 instance directly, e.g. if one already has one configured to their liking. But I prefer your approach.
matthewwithanm commentedon May 29, 2025
Don't get me wrong; I don't have a strong objection or anything. You two should do whatever you think best. (:
EDIT: Oops, just saw that my second point was also raised by @AlexVonB! Serves me right for popping my head in randomly. 😂
AlexVonB commentedon May 29, 2025
:D no worries! Thanks for chiming in! That's a good point. Composition could solve this a bit.
chrispy-snps commentedon May 31, 2025
I don't think passing a
BeautifulSoupobject would work, as the HTML to parse is passed as part of the constructor. And for users working directly withBeautifulSoupobjects (as our application does), they can simply callconvert_soup()as described here.I started working on a pull request to implement a kwargs-based solution, but I ran into a problem - there is no standard way to pass a
dictas an argument value in the shell wrapper script:https://github.com/matthewwithanm/python-markdownify/blob/develop/markdownify/main.py
Perhaps this is a sign to keep the current parser-only option, and if users have more complex needs, they can create their own
BeautifulSoupobjects and callconvert_soup().chrispy-snps commentedon Jun 14, 2025
@AlexVonB, @matthewwithanm - I think I came up with a solution that is the best of both worlds - see #224 and let me know what you think!