Ejemplo n.º 1
0
 def exported_data(self):
     fmt = self.export_format.currentData()
     if fmt == 'calibre_highlights':
         return json.dumps(
             {
                 'version': 1,
                 'type': 'calibre_highlights',
                 'highlights': self.annotations,
             },
             ensure_ascii=False,
             sort_keys=True,
             indent=2)
     lines = []
     as_markdown = fmt == 'md'
     link_prefix = link_prefix_for_location_links()
     chapter_groups = {}
     def_chap = (_('Unknown chapter'), )
     for a in self.annotations:
         toc_titles = a.get('toc_family_titles', def_chap)
         chapter_groups.setdefault(toc_titles[0], []).append(a)
     for chapter, group in chapter_groups.items():
         if len(chapter_groups) > 1:
             lines.append('### ' + chapter)
             lines.append('')
         for hl in group:
             render_highlight_as_text(hl,
                                      lines,
                                      as_markdown=as_markdown,
                                      link_prefix=link_prefix)
     return '\n'.join(lines).strip()
Ejemplo n.º 2
0
 def start_book_load(self,
                     initial_position=None,
                     highlights=None,
                     current_book_data=None):
     key = (set_book_path.path, )
     book_url = link_prefix_for_location_links(add_open_at=False)
     self.execute_when_ready('start_book_load', key, initial_position,
                             set_book_path.pathtoebook, highlights or [],
                             book_url)
Ejemplo n.º 3
0
 def exported_data(self):
     fmt = self.export_format.currentData()
     if fmt == 'calibre_highlights':
         return json.dumps(
             {
                 'version': 1,
                 'type': 'calibre_highlights',
                 'highlights': self.annotations,
             },
             ensure_ascii=False,
             sort_keys=True,
             indent=2)
     lines = []
     as_markdown = fmt == 'md'
     link_prefix = link_prefix_for_location_links()
     for hl in self.annotations:
         render_highlight_as_text(hl,
                                  lines,
                                  as_markdown=as_markdown,
                                  link_prefix=link_prefix)
     return '\n'.join(lines).strip()