mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Input: Do not display section breaks that have a numbering style applied to them. Fixes #1811611 [Word to EPUB adds a digit at the end of some chapters](https://bugs.launchpad.net/calibre/+bug/1811611)
This commit is contained in:
parent
51e6cf8ac4
commit
78f093f1a3
@ -213,12 +213,15 @@ class Styles(object):
|
|||||||
ans = self.para_cache[p] = ParagraphStyle(self.namespace)
|
ans = self.para_cache[p] = ParagraphStyle(self.namespace)
|
||||||
ans.style_name = None
|
ans.style_name = None
|
||||||
direct_formatting = None
|
direct_formatting = None
|
||||||
|
is_section_break = False
|
||||||
for pPr in self.namespace.XPath('./w:pPr')(p):
|
for pPr in self.namespace.XPath('./w:pPr')(p):
|
||||||
ps = ParagraphStyle(self.namespace, pPr)
|
ps = ParagraphStyle(self.namespace, pPr)
|
||||||
if direct_formatting is None:
|
if direct_formatting is None:
|
||||||
direct_formatting = ps
|
direct_formatting = ps
|
||||||
else:
|
else:
|
||||||
direct_formatting.update(ps)
|
direct_formatting.update(ps)
|
||||||
|
if self.namespace.XPath('./w:sectPr')(pPr):
|
||||||
|
is_section_break = True
|
||||||
|
|
||||||
if direct_formatting is None:
|
if direct_formatting is None:
|
||||||
direct_formatting = ParagraphStyle(self.namespace)
|
direct_formatting = ParagraphStyle(self.namespace)
|
||||||
@ -246,7 +249,8 @@ class Styles(object):
|
|||||||
self.para_char_cache[p] = default_para.character_style
|
self.para_char_cache[p] = default_para.character_style
|
||||||
|
|
||||||
is_numbering = direct_formatting.numbering is not inherit
|
is_numbering = direct_formatting.numbering is not inherit
|
||||||
if is_numbering:
|
is_section_break = is_section_break and not self.namespace.XPath('./w:r')(p)
|
||||||
|
if is_numbering and not is_section_break:
|
||||||
num_id, lvl = direct_formatting.numbering
|
num_id, lvl = direct_formatting.numbering
|
||||||
if num_id is not None:
|
if num_id is not None:
|
||||||
p.set('calibre_num_id', '%s:%s' % (lvl, num_id))
|
p.set('calibre_num_id', '%s:%s' % (lvl, num_id))
|
||||||
@ -254,7 +258,9 @@ class Styles(object):
|
|||||||
ps = self.numbering.get_para_style(num_id, lvl)
|
ps = self.numbering.get_para_style(num_id, lvl)
|
||||||
if ps is not None:
|
if ps is not None:
|
||||||
parent_styles.append(ps)
|
parent_styles.append(ps)
|
||||||
if not is_numbering and linked_style is not None and getattr(linked_style.paragraph_style, 'numbering', inherit) is not inherit:
|
if (
|
||||||
|
not is_numbering and not is_section_break and linked_style is not None and getattr(
|
||||||
|
linked_style.paragraph_style, 'numbering', inherit) is not inherit):
|
||||||
num_id, lvl = linked_style.paragraph_style.numbering
|
num_id, lvl = linked_style.paragraph_style.numbering
|
||||||
if num_id is not None:
|
if num_id is not None:
|
||||||
p.set('calibre_num_id', '%s:%s' % (lvl, num_id))
|
p.set('calibre_num_id', '%s:%s' % (lvl, num_id))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user