markdownify 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdownify
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Convert HTML to markdown.
5
5
  Author-email: Matthew Tretter <m@tthewwithanm.com>
6
6
  Project-URL: Homepage, http://github.com/matthewwithanm/python-markdownify
@@ -106,6 +106,7 @@ def should_remove_whitespace_inside(el):
106
106
  return el.name in ('p', 'blockquote',
107
107
  'article', 'div', 'section',
108
108
  'ol', 'ul', 'li',
109
+ 'dl', 'dt', 'dd',
109
110
  'table', 'thead', 'tbody', 'tfoot',
110
111
  'tr', 'td', 'th')
111
112
 
@@ -442,7 +443,7 @@ class MarkdownConverter(object):
442
443
 
443
444
  def convert_br(self, el, text, parent_tags):
444
445
  if '_inline' in parent_tags:
445
- return ""
446
+ return ' '
446
447
 
447
448
  if self.options['newline_style'].lower() == BACKSLASH:
448
449
  return '\\\n'
@@ -489,6 +490,11 @@ class MarkdownConverter(object):
489
490
 
490
491
  return '%s\n' % text
491
492
 
493
+ # definition lists are formatted as follows:
494
+ # https://pandoc.org/MANUAL.html#definition-lists
495
+ # https://michelf.ca/projects/php-markdown/extra/#def-list
496
+ convert_dl = convert_div
497
+
492
498
  def convert_dt(self, el, text, parent_tags):
493
499
  # remove newlines from term text
494
500
  text = (text or '').strip()
@@ -501,7 +507,7 @@ class MarkdownConverter(object):
501
507
  # TODO - format consecutive <dt> elements as directly adjacent lines):
502
508
  # https://michelf.ca/projects/php-markdown/extra/#def-list
503
509
 
504
- return '\n%s\n' % text
510
+ return '\n\n%s\n' % text
505
511
 
506
512
  def _convert_hn(self, n, el, text, parent_tags):
507
513
  """ Method name prefixed with _ to prevent <hn> to call this """
@@ -538,6 +544,24 @@ class MarkdownConverter(object):
538
544
 
539
545
  return '![%s](%s%s)' % (alt, src, title_part)
540
546
 
547
+ def convert_video(self, el, text, parent_tags):
548
+ if ('_inline' in parent_tags
549
+ and el.parent.name not in self.options['keep_inline_images_in']):
550
+ return text
551
+ src = el.attrs.get('src', None) or ''
552
+ if not src:
553
+ sources = el.find_all('source', attrs={'src': True})
554
+ if sources:
555
+ src = sources[0].attrs.get('src', None) or ''
556
+ poster = el.attrs.get('poster', None) or ''
557
+ if src and poster:
558
+ return '[![%s](%s)](%s)' % (text, poster, src)
559
+ if src:
560
+ return '[%s](%s)' % (text, src)
561
+ if poster:
562
+ return '![%s](%s)' % (text, poster)
563
+ return text
564
+
541
565
  def convert_list(self, el, text, parent_tags):
542
566
 
543
567
  # Converting a list to inline is undefined.
@@ -677,6 +701,12 @@ class MarkdownConverter(object):
677
701
  )
678
702
  overline = ''
679
703
  underline = ''
704
+ full_colspan = 0
705
+ for cell in cells:
706
+ if 'colspan' in cell.attrs and cell['colspan'].isdigit():
707
+ full_colspan += int(cell["colspan"])
708
+ else:
709
+ full_colspan += 1
680
710
  if ((is_headrow
681
711
  or (is_head_row_missing
682
712
  and self.options['table_infer_header']))
@@ -685,12 +715,6 @@ class MarkdownConverter(object):
685
715
  # - is headline or
686
716
  # - headline is missing and header inference is enabled
687
717
  # print headline underline
688
- full_colspan = 0
689
- for cell in cells:
690
- if 'colspan' in cell.attrs and cell['colspan'].isdigit():
691
- full_colspan += int(cell["colspan"])
692
- else:
693
- full_colspan += 1
694
718
  underline += '| ' + ' | '.join(['---'] * full_colspan) + ' |' + '\n'
695
719
  elif ((is_head_row_missing
696
720
  and not self.options['table_infer_header'])
@@ -703,8 +727,8 @@ class MarkdownConverter(object):
703
727
  # - the parent is table or
704
728
  # - the parent is tbody at the beginning of a table.
705
729
  # print empty headline above this row
706
- overline += '| ' + ' | '.join([''] * len(cells)) + ' |' + '\n'
707
- overline += '| ' + ' | '.join(['---'] * len(cells)) + ' |' + '\n'
730
+ overline += '| ' + ' | '.join([''] * full_colspan) + ' |' + '\n'
731
+ overline += '| ' + ' | '.join(['---'] * full_colspan) + ' |' + '\n'
708
732
  return overline + '|' + text + '\n' + underline
709
733
 
710
734
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdownify
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Convert HTML to markdown.
5
5
  Author-email: Matthew Tretter <m@tthewwithanm.com>
6
6
  Project-URL: Homepage, http://github.com/matthewwithanm/python-markdownify
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "markdownify"
7
- version = "1.0.0"
7
+ version = "1.1.0"
8
8
  authors = [{name = "Matthew Tretter", email = "m@tthewwithanm.com"}]
9
9
  description = "Convert HTML to markdown."
10
10
  readme = "README.rst"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes