forked from LiveCarta/BookConverter
fix heading in json 3.0
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user