def visitNode_pre(self, node): """ Writes a I{verbatim} block when it encounters a I{pre} element. @param node: The element to process. @type node: L{xml.dom.minidom.Element} """ self.writer('@verbatim\n') buf = StringIO() latex.getLatexText(node, buf.write, entities=entities) self.writer(tree._removeLeadingTrailingBlankLines(buf.getvalue())) self.writer('@end verbatim\n')
def visitNode_pre(self, node): """ Writes a I{verbatim} block when it encounters a I{pre} element. @param node: The element to process. @type node: L{xml.dom.minidom.Element} """ self.writer('\\begin{verbatim}\n') buf = StringIO() getLatexText(node, buf.write) self.writer(tree._removeLeadingTrailingBlankLines(buf.getvalue())) self.writer('\\end{verbatim}\n')
def visitNode_a_listing(self, node): """ Writes a I{verbatim} block when it encounters a code listing (represented by an I{a} element with a I{listing} class). @param node: The element to process. @type node: C{xml.dom.minidom.Element} """ fileName = os.path.join(self.currDir, node.getAttribute('href')) self.writer('\\begin{verbatim}\n') lines = map(str.rstrip, open(fileName).readlines()) skipLines = int(node.getAttribute('skipLines') or 0) lines = lines[skipLines:] self.writer(tree._removeLeadingTrailingBlankLines('\n'.join(lines))) self.writer('\\end{verbatim}') # Write a caption for this source listing fileName = os.path.basename(fileName) caption = domhelpers.getNodeText(node) if caption == fileName: caption = 'Source listing' self.writer('\parbox[b]{\linewidth}{\\begin{center}%s --- ' '\\begin{em}%s\\end{em}\\end{center}}' % (latexEscape(caption), latexEscape(fileName)))