本文整理汇总了Python中calibre.ebooks.docx.styles.Styles.class_name方法的典型用法代码示例。如果您正苦于以下问题:Python Styles.class_name方法的具体用法?Python Styles.class_name怎么用?Python Styles.class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.ebooks.docx.styles.Styles
的用法示例。
在下文中一共展示了Styles.class_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Convert
# 需要导入模块: from calibre.ebooks.docx.styles import Styles [as 别名]
# 或者: from calibre.ebooks.docx.styles.Styles import class_name [as 别名]
#.........这里部分代码省略.........
self.resolve_links()
self.styles.cascade(self.layers)
self.tables.apply_markup(self.object_map, self.page_map)
numbered = []
for html_obj, obj in self.object_map.iteritems():
raw = obj.get('calibre_num_id', None)
if raw is not None:
lvl, num_id = raw.partition(':')[0::2]
try:
lvl = int(lvl)
except (TypeError, ValueError):
lvl = 0
numbered.append((html_obj, num_id, lvl))
self.numbering.apply_markup(numbered, self.body, self.styles, self.object_map, self.images)
self.apply_frames()
if len(self.body) > 0:
self.body.text = '\n\t'
for child in self.body:
child.tail = '\n\t'
self.body[-1].tail = '\n'
self.log.debug('Converting styles to CSS')
self.styles.generate_classes()
for html_obj, obj in self.object_map.iteritems():
style = self.styles.resolve(obj)
if style is not None:
css = style.css
if css:
cls = self.styles.class_name(css)
if cls:
html_obj.set('class', cls)
for html_obj, css in self.framed_map.iteritems():
cls = self.styles.class_name(css)
if cls:
html_obj.set('class', cls)
if notes_header is not None:
for h in children(self.body, 'h1', 'h2', 'h3'):
notes_header.tag = h.tag
cls = h.get('class', None)
if cls and cls != 'notes-header':
notes_header.set('class', '%s notes-header' % cls)
break
self.fields.polish_markup(self.object_map)
self.log.debug('Cleaning up redundant markup generated by Word')
self.cover_image = cleanup_markup(self.log, self.html, self.styles, self.dest_dir, self.detect_cover)
return self.write(doc)
def read_page_properties(self, doc):
current = []
self.page_map = OrderedDict()
self.section_starts = []
for p in descendants(doc, 'w:p', 'w:tbl'):
if p.tag.endswith('}tbl'):
self.tables.register(p, self.styles)
current.append(p)
continue
示例2: Convert
# 需要导入模块: from calibre.ebooks.docx.styles import Styles [as 别名]
# 或者: from calibre.ebooks.docx.styles.Styles import class_name [as 别名]
#.........这里部分代码省略.........
dl[-1].append(p)
self.resolve_links(relationships_by_id)
self.styles.cascade(self.layers)
self.tables.apply_markup(self.object_map)
numbered = []
for html_obj, obj in self.object_map.iteritems():
raw = obj.get("calibre_num_id", None)
if raw is not None:
lvl, num_id = raw.partition(":")[0::2]
try:
lvl = int(lvl)
except (TypeError, ValueError):
lvl = 0
numbered.append((html_obj, num_id, lvl))
self.numbering.apply_markup(numbered, self.body, self.styles, self.object_map)
self.apply_frames()
if len(self.body) > 0:
self.body.text = "\n\t"
for child in self.body:
child.tail = "\n\t"
self.body[-1].tail = "\n"
self.styles.generate_classes()
for html_obj, obj in self.object_map.iteritems():
style = self.styles.resolve(obj)
if style is not None:
css = style.css
if css:
cls = self.styles.class_name(css)
if cls:
html_obj.set("class", cls)
for html_obj, css in self.framed_map.iteritems():
cls = self.styles.class_name(css)
if cls:
html_obj.set("class", cls)
if notes_header is not None:
for h in self.body.iterchildren("h1", "h2", "h3"):
notes_header.tag = h.tag
cls = h.get("class", None)
if cls and cls != "notes-header":
notes_header.set("class", "%s notes-header" % cls)
break
return self.write()
def read_page_properties(self, doc):
current = []
self.page_map = OrderedDict()
in_table = False
for p in descendants(doc, "w:p", "w:tbl"):
if p.tag.endswith("}tbl"):
in_table = True
self.tables.register(p)
continue
sect = tuple(descendants(p, "w:sectPr"))
if sect:
pr = PageProperties(sect)
for x in current + [p]:
示例3: Convert
# 需要导入模块: from calibre.ebooks.docx.styles import Styles [as 别名]
# 或者: from calibre.ebooks.docx.styles.Styles import class_name [as 别名]
#.........这里部分代码省略.........
dl[-1].append(p)
self.resolve_links(relationships_by_id)
self.styles.cascade(self.layers)
self.tables.apply_markup(self.object_map, self.page_map)
numbered = []
for html_obj, obj in self.object_map.iteritems():
raw = obj.get('calibre_num_id', None)
if raw is not None:
lvl, num_id = raw.partition(':')[0::2]
try:
lvl = int(lvl)
except (TypeError, ValueError):
lvl = 0
numbered.append((html_obj, num_id, lvl))
self.numbering.apply_markup(numbered, self.body, self.styles, self.object_map)
self.apply_frames()
if len(self.body) > 0:
self.body.text = '\n\t'
for child in self.body:
child.tail = '\n\t'
self.body[-1].tail = '\n'
self.styles.generate_classes()
for html_obj, obj in self.object_map.iteritems():
style = self.styles.resolve(obj)
if style is not None:
css = style.css
if css:
cls = self.styles.class_name(css)
if cls:
html_obj.set('class', cls)
for html_obj, css in self.framed_map.iteritems():
cls = self.styles.class_name(css)
if cls:
html_obj.set('class', cls)
if notes_header is not None:
for h in children(self.body, 'h1', 'h2', 'h3'):
notes_header.tag = h.tag
cls = h.get('class', None)
if cls and cls != 'notes-header':
notes_header.set('class', '%s notes-header' % cls)
break
return self.write()
def read_page_properties(self, doc):
current = []
self.page_map = OrderedDict()
for p in descendants(doc, 'w:p', 'w:tbl'):
if p.tag.endswith('}tbl'):
self.tables.register(p, self.styles)
current.append(p)
continue
sect = tuple(descendants(p, 'w:sectPr'))
if sect:
pr = PageProperties(sect)
for x in current + [p]:
self.page_map[x] = pr
current = []