mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Output: Better naming of styles
This commit is contained in:
parent
95ebc11105
commit
5a693a641c
@ -500,24 +500,24 @@ class StylesManager(object):
|
|||||||
block_counts[block.style] += 1
|
block_counts[block.style] += 1
|
||||||
block_rmap[block.style].append(block)
|
block_rmap[block.style].append(block)
|
||||||
for run in block.runs:
|
for run in block.runs:
|
||||||
run_counts[run.style] += 1
|
run_counts[run.style] += (0 if run.is_empty() else 1)
|
||||||
run_rmap[run.style].append(run)
|
run_rmap[run.style].append(run)
|
||||||
|
bnum = len(str(max(1, len(block_counts) - 1)))
|
||||||
for i, (block_style, count) in enumerate(block_counts.most_common()):
|
for i, (block_style, count) in enumerate(block_counts.most_common()):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
self.normal_block_style = block_style
|
self.normal_block_style = block_style
|
||||||
block_style.id = 'ParagraphNormal'
|
block_style.id = 'ParagraphNormal'
|
||||||
block_style.name = 'Normal'
|
|
||||||
else:
|
else:
|
||||||
block_style.id = 'Paragraph%d' % i
|
block_style.id = 'Paragraph%d' % i
|
||||||
block_style.name = 'Paragraph %d' % i
|
block_style.name = '%0{}d Para'.format(bnum) % i
|
||||||
|
rnum = len(str(max(1, len(run_counts) - 1)))
|
||||||
for i, (text_style, count) in enumerate(run_counts.most_common()):
|
for i, (text_style, count) in enumerate(run_counts.most_common()):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
self.normal_text_style = text_style
|
self.normal_text_style = text_style
|
||||||
text_style.id = 'TextNormal'
|
text_style.id = 'TextNormal'
|
||||||
text_style.name = 'Normal'
|
|
||||||
else:
|
else:
|
||||||
text_style.id = 'Text%d' % i
|
text_style.id = 'Text%d' % i
|
||||||
text_style.name = 'Text %d' % i
|
text_style.name = '%0{}d Text'.format(rnum) % i
|
||||||
for s in tuple(self.block_styles):
|
for s in tuple(self.block_styles):
|
||||||
if s.id is None:
|
if s.id is None:
|
||||||
self.block_styles.pop(s)
|
self.block_styles.pop(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user