diff --git a/markdownify/__init__.py b/markdownify/__init__.py index fd03569..ac53077 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -319,6 +319,38 @@ def convert_code(self, el, text, convert_as_inline): convert_kbd = convert_code + def convert_dd(self, el, text, convert_as_inline): + text = (text or '').strip() + if convert_as_inline: + return ' ' + text + ' ' + if not text: + return '\n' + + # indent definition content lines by four spaces + def _indent_for_dd(match): + line_content = match.group(1) + return ' ' + line_content if line_content else '' + text = line_with_content_re.sub(_indent_for_dd, text) + + # insert definition marker into first-line indent whitespace + text = ':' + text[1:] + + return '%s\n' % text + + def convert_dt(self, el, text, convert_as_inline): + # remove newlines from term text + text = (text or '').strip() + text = all_whitespace_re.sub(' ', text) + if convert_as_inline: + return ' ' + text + ' ' + if not text: + return '\n' + + # TODO - format consecutive
foobarbaz
', sub_symbol='^') == '`foobarbaz`'
+def test_dl():
+ assert md('te
rm
definition-p1
definition-p2
definition 1
definition 2
line 1
line 2
1
3