예제 #1
0
 def translate(self):
     destination_path = self.destination.destination_path
     if destination_path not in ('<stdout>', '<string>'):  # there is a specified destination
         dest_dir, extension = splitext(destination_path)
         if extension:  # there is a filename in the destination
             dest_dir, dest_filename = split(destination_path)
         else:  # The specified destination is a directory. A new filename is necessary
             dest_filename = splitext(basename(self.document.settings._source))[0] + '.html'
         self.destination = FileOutput(destination_path=join(dest_dir, dest_filename),
                                       encoding='utf-8')
     HTML5Writer.translate(self)
     self.rebuild_output()
     return
예제 #2
0
    def _rst2html(self,
                  source,
                  source_path=None,
                  source_class=docutils.io.StringInput,
                  destination_path=None,
                  reader=None,
                  reader_name='standalone',
                  parser=None,
                  parser_name='restructuredtext',
                  writer=None,
                  writer_name=None,
                  settings=None,
                  settings_spec=None,
                  settings_overrides=None,
                  config_section=None,
                  enable_exit_status=None):

        if not writer:
            writer = HTML5Writer()

        # Taken from Nikola
        # http://bit.ly/14CmQyh
        output, pub = docutils.core.publish_programmatically(
            source=source,
            source_path=source_path,
            source_class=source_class,
            destination_class=docutils.io.StringOutput,
            destination=None,
            destination_path=destination_path,
            reader=reader,
            reader_name=reader_name,
            parser=parser,
            parser_name=parser_name,
            writer=writer,
            writer_name=writer_name,
            settings=settings,
            settings_spec=settings_spec,
            settings_overrides=settings_overrides,
            config_section=config_section,
            enable_exit_status=enable_exit_status)
        return pub.writer.parts['body']
예제 #3
0
 def get_transforms(self):
     return HTML5Writer.get_transforms(self) + [SlideTransform]
예제 #4
0
 def __init__(self):
     HTML5Writer.__init__(self)
     self.translator_class = SlideTranslator