Skip to content

Commit

Permalink
handling google paragraph seperators
Browse files Browse the repository at this point in the history
  • Loading branch information
Yariv Barkan committed Sep 14, 2011
1 parent 4f5e385 commit da856dd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion html2text.py
Expand Up @@ -188,6 +188,18 @@ def google_nest_count(attrs, style_def):
nest_count = int(css_style['margin-left'][:-2]) / 36
return nest_count

def google_has_height(attrs, style_def):
"""calculate the nesting count of google doc lists"""
if attrs is None:
return False
x = dict(attrs)
nest_count = 0
for css_class in x['class'].split():
css_style = style_def['.' + css_class]
if 'height' in css_style:
return True
return False

def list_numbering_start(attrs, style_def):
"""extract numbering from list element attributes"""
x = dict(attrs)
Expand Down Expand Up @@ -283,7 +295,10 @@ def handle_tag(self, tag, attrs, start):

if tag in ['p', 'div']:
if options.google_doc:
self.soft_br()
if google_has_height(attrs, self.style_def):
self.p()
else:
self.soft_br()
else:
self.p()

Expand Down

0 comments on commit da856dd

Please sign in to comment.