def _generate_page(fname, org_doc, site, folder): """Generate the HTML for an org file and place it in the output""" html_file = os.path.splitext(fname)[0] + '.html' # generate the html for the org document html = org_to_html(org_doc, \ hl_offset = site.config['hl_offset'], \ remove_empty_p = site.config['remove_empty_p']) html = html.decode('utf8') if folder == '': inner_path = '' else: inner_path = folder + '/' # create the page object page = Page(org_doc.options['TITLE'], \ html_file, \ org_doc.options['DATE'], \ html, \ url = site.config['root'] + '/' + inner_path + html_file) return page
print 'Need to specify input file' usage() input_file = args[0] try: fin = open(input_file, 'r') except IOError: print 'Could not find', input_file org_tree = parser.parse(fin) fin.close() if output: try: out = open(output, 'w') except IOError, e: print e sys.exit(1) else: out = sys.stdout out.write(str(org_to_html(org_tree, **export_options))) out.close()
def _assert_html(self, org_str, html_str, **export_options): """Helper method to assert the HTML representation of a given org string is what it should be. """ doc = parser.parse(org_str) self.assertEqual(org_to_html(doc, **export_options), html_str)