def serialize_item(self, name): mt = (self.mime_map[name] or '').lower() if mt in OEB_STYLES: ans = ContainerBase.serialize_item(self, name).lstrip() if not ans.startswith(b'@charset'): ans = b'@charset "UTF-8";\n' + ans return ans if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) root = self.parsed(name) return json.dumps(html_as_dict(root), ensure_ascii=False, separators=(',', ':')).encode('utf-8')
def serialize_item(self, name): mt = (self.mime_map[name] or '').lower() if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) root = self.parsed(name) return json.dumps(html_as_dict(root), ensure_ascii=False, separators=(',', ':')).encode('utf-8')
def serialize_item(self, name): mt = self.mime_map[name] if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) # Normalize markup root = self.parsed(name) for comment in tuple(root.iterdescendants(Comment)): comment.getparent().remove(comment) escape_cdata(root) return tostring(root, encoding='utf-8', xml_declaration=True, with_tail=False, doctype='<!DOCTYPE html>')
def serialize_item(self, name): mt = self.mime_map[name] if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) # Normalize markup root = self.parsed(name) for comment in tuple(root.iterdescendants(Comment)): comment.getparent().remove(comment) escape_cdata(root) return tostring(root, encoding='utf-8', xml_declaration=True, with_tail=False, doctype='<!DOCTYPE html>')
def serialize_item(self, name): mt = (self.mime_map[name] or '').lower() if mt not in OEB_DOCS: return ContainerBase.serialize_item(self, name) root = self.parsed(name) return json.dumps(html_as_dict(root), ensure_ascii=False, separators=(',', ':')).encode('utf-8')