Example #1
0
    def process_node_create_html(self, nodeid):
        if self.options.verbose:
            print 'html', nodeid
        errors = 0
        infile = os.path.join('src', self.book.name, self.stage_name,
                              nodeid + '.txt')
        success = True
        try:
            parser = Parser(self, self.options)
            if not parser.parse(infile, nodeid, todo=True):
                success = False
        except Exception as e:
            print 'Exception:', e
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value, exc_traceback)
            success = False

        if not success:
            print '%s' % nodeid
            print 'Parse failure'
            errors += 1
            sys.exit(0)
        parser.export_html(
            os.path.join(self.book.name, self.stage_name, nodeid + '.html'))

        return errors
Example #2
0
    def process_html(self, infile, outfile, options):
        """
		Process simple (non-node) src file and generate an HTML file.
		"""
        errors = 0
        name = os.path.splitext(os.path.basename(infile))[0]
        make_dir(os.path.dirname(outfile))
        success = True
        if options.verbose:
            print '  %s -> html' % infile
        try:
            parser = Parser(None, options)
            if not parser.parse(infile, name):
                print 'Failure during parse_main'
                success = False
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value, exc_traceback)
            success = False

        if not success:
            print '%s' % file
            print 'Parse failure'
            errors += 1
        else:
            parser.export_html(outfile)

        return errors