fix heading in json 3.0

This commit is contained in:
shirshasa
2020-09-28 16:40:20 +03:00
parent e913a5f49a
commit 5917fe51e0
2 changed files with 9 additions and 12 deletions

View File

@@ -512,7 +512,7 @@ class HTMLPreprocessor:
for i in range(0, len(self.top_level_headers)):
self.top_level_headers[i]['should_be_numbered'] = True
def _dfs(self, tag, is_first_span=None):
def _clean_header_by_children(self, tag, is_first_span=None):
children = tag.find_all(recursive=False)
if not children:
text = tag.text
@@ -525,9 +525,9 @@ class HTMLPreprocessor:
for i, child in enumerate(tag.find_all(recursive=False)):
if is_first_span and i == 0:
self._dfs(child, True)
self._clean_header_by_children(child, True)
else:
self._dfs(child)
self._clean_header_by_children(child)
def _process_headings(self):
"""
@@ -548,7 +548,7 @@ class HTMLPreprocessor:
assert tag.name in LawCartaConfig.SUPPORTED_HEADERS, \
f'Preprocessing went wrong, there is still h{LawCartaConfig.SUPPORTED_LEVELS + 1}-h9 headings.'
self._dfs(tag, is_first_span=True)
self._clean_header_by_children(tag, is_first_span=True)
span_with_style_font = tag.find_all("span", {'style': re.compile(r'^font.+')})
if span_with_style_font: