def fontifyPythonNode(node): """ Syntax color the given node containing Python source code. The node must have a parent. @return: C{None} """ oldio = cStringIO.StringIO() latex.getLatexText(node, oldio.write, entities={ 'lt': '<', 'gt': '>', 'amp': '&' }) oldio = cStringIO.StringIO(oldio.getvalue().strip() + '\n') howManyLines = len(oldio.getvalue().splitlines()) newio = cStringIO.StringIO() htmlizer.filter(oldio, newio, writer=htmlizer.SmallerHTMLWriter) lineLabels = _makeLineNumbers(howManyLines) newel = dom.parseString(newio.getvalue()).documentElement newel.setAttribute("class", "python") node.parentNode.replaceChild(newel, node) newel.insertBefore(lineLabels, newel.firstChild)
def fontifyPythonNode(node): oldio = cStringIO.StringIO() latex.getLatexText(node, oldio.write, entities={'lt': '<', 'gt': '>', 'amp': '&'}) oldio = cStringIO.StringIO(oldio.getvalue().strip()+'\n') newio = cStringIO.StringIO() htmlizer.filter(oldio, newio, writer=htmlizer.SmallerHTMLWriter) newio.seek(0) newel = microdom.parse(newio).documentElement newel.setAttribute("class", "python") node.parentNode.replaceChild(newel, node)
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 fontifyPythonNode(node): """ Syntax color the given node containing Python source code. @return: C{None} """ oldio = cStringIO.StringIO() latex.getLatexText(node, oldio.write, entities={"lt": "<", "gt": ">", "amp": "&"}) oldio = cStringIO.StringIO(oldio.getvalue().strip() + "\n") newio = cStringIO.StringIO() htmlizer.filter(oldio, newio, writer=htmlizer.SmallerHTMLWriter) newio.seek(0) newel = microdom.parse(newio).documentElement newel.setAttribute("class", "python") node.parentNode.replaceChild(newel, node)
def fontifyPythonNode(node): """ Syntax color the given node containing Python source code. @return: C{None} """ oldio = cStringIO.StringIO() latex.getLatexText(node, oldio.write, entities={'lt': '<', 'gt': '>', 'amp': '&'}) oldio = cStringIO.StringIO(oldio.getvalue().strip()+'\n') newio = cStringIO.StringIO() htmlizer.filter(oldio, newio, writer=htmlizer.SmallerHTMLWriter) newio.seek(0) newel = microdom.parse(newio).documentElement newel.setAttribute("class", "python") node.parentNode.replaceChild(newel, node)
def fontifyPythonNode(node): """ Syntax color the given node containing Python source code. The node must have a parent. @return: C{None} """ oldio = cStringIO.StringIO() latex.getLatexText(node, oldio.write, entities={'lt': '<', 'gt': '>', 'amp': '&'}) oldio = cStringIO.StringIO(oldio.getvalue().strip()+'\n') howManyLines = len(oldio.getvalue().splitlines()) newio = cStringIO.StringIO() htmlizer.filter(oldio, newio, writer=htmlizer.SmallerHTMLWriter) lineLabels = _makeLineNumbers(howManyLines) newel = dom.parseString(newio.getvalue()).documentElement newel.setAttribute("class", "python") node.parentNode.replaceChild(newel, node) newel.insertBefore(lineLabels, newel.firstChild)
def visitNode_code(self, node): fout = StringIO() latex.getLatexText(node, fout.write, texiEscape, entities) self.writer('@code{'+fout.getvalue()+'}')
def visitNode_pre(self, node): self.writer('@verbatim\n') buf = StringIO() latex.getLatexText(node, buf.write, entities=entities) self.writer(text.removeLeadingTrailingBlanks(buf.getvalue())) self.writer('@end verbatim\n')
def writeNodeData(self, node): buf = StringIO() latex.getLatexText(node, self.writer, texiEscape, entities)
def visitNode_code(self, node): fout = StringIO() latex.getLatexText(node, fout.write, texiEscape, entities) self.writer('@code{' + fout.getvalue() + '}')
def writeNodeData(self, node): latex.getLatexText(node, self.writer, texiEscape, entities)