Skip to content

Conversation

Fess-AKA-DeadMonk
Copy link
Contributor

html tags may contain symbols like : and - which are not suitable for the python function names
simple name converter allows usage of the methods for tags like tag:subtag-name

@chrispy-snps
Copy link
Collaborator

chrispy-snps commented Jan 1, 2025

@Fess-AKA-DeadMonk - thanks for submitting this pull request!

I have two suggestions:

  1. Include [ and ] in the translation set (as BeautifulSoup objects have a name value of [document], and this would enable the creation of soup-level conversion functions).

  2. Move the creation of the translation dictionary to be a global value so it is only computed once:

    tag_name_translation = ''.maketrans(':-[]', '____')
    

@chrispy-snps
Copy link
Collaborator

@Fess-AKA-DeadMonk - if you are able to make the changes suggested above, we can review and approve this pull request. Thanks!

@chrispy-snps chrispy-snps changed the title fixed the way the converter is chosen for tags with names containing symbols not suitable for python def for convert_* functions, allow for tags with special characters in their name (like "subtag-name") Jan 19, 2025
…symbols not suitable for python def

html tags may contain symbols like `:` and `-` which are not suitable for the python function names
simple name converter allows usage of the methods for tags like `tag:subtag-name`
@chrispy-snps chrispy-snps force-pushed the develop branch 2 times, most recently from a2f4c3b to bd4c46d Compare January 19, 2025 14:13
Signed-off-by: chrispy <[email protected]>
@chrispy-snps chrispy-snps merged commit 1b33330 into matthewwithanm:develop Jan 19, 2025
1 check passed
@chrispy-snps
Copy link
Collaborator

@Fess-AKA-DeadMonk - the support for BeautifulSoup objects is best left to #174, so I added a unit test and merged your branch. Thanks for your contribution!

Wuhall pushed a commit to Wuhall/python-markdownify that referenced this pull request May 21, 2025
…eir name (like "subtag-name") (matthewwithanm#136)

support custom conversion functions for tags with `:` and `-` characters in their names by mapping them to underscores in the function name
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.

2 participants