def process(op): text = op.input.read() kwargs = dict( navigation=op.navigation, source_path=op.path, operation=op, ) if re.search( r'^\.\.\s+include::\s+<s5defs.txt>\s*$', text, flags=re.MULTILINE, ): kwargs['flavor'] = 's5' try: # TODO do a proper globbing lookup theme = op.config.get( section='input %s' % op.path, option='s5-theme-url', ) except ( ConfigParser.NoSectionError, ConfigParser.NoOptionError, ): theme = '/s5-themes/medium-white' #TODO kwargs['s5_theme_url'] = theme else: kwargs['flavor'] = 'html' template = _lookUp(op, '_template.html') if template is not None: try: kwargs['template'] = template.read() finally: template.close() tree = rst.asDOM(text, **kwargs) depth = op.path.count('/') _fixLinks(tree, depth) html = tree.toxml('utf-8') base, ext = os.path.splitext(op.path) dst = '%s.html' % base f = op.open_output(dst) try: f.write(html) f.write('\n') finally: f.close()
def get_navigation(text): dom = rst.asDOM(text) return get_sections(dom)
def test_simple(self): src = self.slurp('data', 'comment', 'input', 'index.rst') dom = rst.asDOM(src) got = dom.toxml('utf-8') self.verify(got, 'data', 'comment', 'output', 'index.html')