예제 #1
0
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)
예제 #2
0
파일: tree.py 프로젝트: galaxysd/BitTorrent
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)
예제 #3
0
    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')
예제 #4
0
    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')
예제 #5
0
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)
예제 #6
0
파일: tree.py 프로젝트: emragins/tribal
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)
예제 #7
0
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)
예제 #8
0
파일: texi.py 프로젝트: Almad/twisted
 def visitNode_code(self, node):
     fout = StringIO()
     latex.getLatexText(node, fout.write, texiEscape, entities)
     self.writer('@code{'+fout.getvalue()+'}')
예제 #9
0
파일: texi.py 프로젝트: Almad/twisted
 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')
예제 #10
0
파일: texi.py 프로젝트: Almad/twisted
 def writeNodeData(self, node):
     buf = StringIO()
     latex.getLatexText(node, self.writer, texiEscape, entities)
예제 #11
0
 def visitNode_code(self, node):
     fout = StringIO()
     latex.getLatexText(node, fout.write, texiEscape, entities)
     self.writer('@code{' + fout.getvalue() + '}')
예제 #12
0
 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')
예제 #13
0
 def writeNodeData(self, node):
     buf = StringIO()
     latex.getLatexText(node, self.writer, texiEscape, entities)
예제 #14
0
 def writeNodeData(self, node):
     latex.getLatexText(node, self.writer, texiEscape, entities)
예제 #15
0
파일: texi.py 프로젝트: 0004c/VTK
 def writeNodeData(self, node):
     latex.getLatexText(node, self.writer, texiEscape, entities)