Skip to content

Commit fcc98e2

Browse files
fixed the way the converter is chosen for tags with names containing 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`
1 parent 0a5c89a commit fcc98e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

markdownify/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def is_nested_node(el):
151151
text += self.process_tag(el, convert_children_as_inline)
152152

153153
if not children_only:
154-
convert_fn = getattr(self, 'convert_%s' % node.name, None)
154+
fn_name = 'convert_%s' % node.name.translate(''.maketrans(':-', '__'))
155+
convert_fn = getattr(self, fn_name, None)
155156
if convert_fn and self.should_convert_tag(node.name):
156157
text = convert_fn(node, text, convert_as_inline)
157158

0 commit comments

Comments
 (0)