def testHighlightCode(self): """ <pre><code language="sh">echo one echo two </code></pre> """ print(oil_doc.HighlightCode(TEST_HTML))
def testPygmentsPlugin(self): # TODO: Doesn't pass on Travis because pygments isn't there # use virtualenv or something? return HTML = ''' <pre><code class="language-sh"> echo hi > out.txt </code></pre> ''' h = oil_doc.HighlightCode(HTML) # assert there's no double escaping self.assert_('hi > out.txt' in h, h)
def testPygmentsPlugin(self): # This test depends on pygments being installed, which isn't on Travis. # TODO: Add it to Nix? return HTML = ''' <pre><code class="language-sh"> echo hi > out.txt </code></pre> ''' h = oil_doc.HighlightCode(HTML) # assert there's no double escaping self.assert_('hi > out.txt' in h, h) print(h)
def Render(opts, in_file, out_file, use_fastlex=True): html = md2html(in_file.read()) if use_fastlex: html = oil_doc.RemoveComments(html) # Hack for allowing tables without <p> in cells, which CommonMark seems to require? html = html.replace('<p><pstrip>', '') html = html.replace('</pstrip></p>', '') # Stages of transformation. html = oil_doc.ExpandLinks(html) html = oil_doc.HighlightCode(html) # h2 is the title. h1 is unused. if opts.toc_tags: toc_tags = opts.toc_tags else: toc_tags = ('h3', 'h4') parser = TocExtractor() parser.feed(html) log('') log('*** HTML headings:') for heading in parser.headings: log(heading) if parser.toc_begin_line == -1: # Not found! out_file.write(html) # Pass through return insertions = _MakeTocAndAnchors(opts, toc_tags, parser.headings, parser.toc_begin_line) log('') log('*** Text Insertions:') for ins in insertions: log(ins) log('') log('*** Output:') lines = html.splitlines(True) # keep newlines _ApplyInsertions(lines, insertions, out_file)
def testHighlightCode(self): # lazylex/testdata.html has the language-sh-prompt h = oil_doc.HighlightCode(TEST_HTML) self.assert_('<span class="sh-prompt">' in h, h)