Exemplo n.º 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)
Exemplo n.º 2
0
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)
Exemplo n.º 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')
Exemplo 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')
Exemplo 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)
Exemplo n.º 6
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)
Exemplo n.º 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)
Exemplo n.º 8
0
 def visitNode_code(self, node):
     fout = StringIO()
     latex.getLatexText(node, fout.write, texiEscape, entities)
     self.writer('@code{'+fout.getvalue()+'}')
Exemplo n.º 9
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')
Exemplo n.º 10
0
 def writeNodeData(self, node):
     buf = StringIO()
     latex.getLatexText(node, self.writer, texiEscape, entities)
Exemplo n.º 11
0
 def visitNode_code(self, node):
     fout = StringIO()
     latex.getLatexText(node, fout.write, texiEscape, entities)
     self.writer('@code{' + fout.getvalue() + '}')
Exemplo n.º 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')
Exemplo n.º 13
0
 def writeNodeData(self, node):
     buf = StringIO()
     latex.getLatexText(node, self.writer, texiEscape, entities)
Exemplo n.º 14
0
 def writeNodeData(self, node):
     latex.getLatexText(node, self.writer, texiEscape, entities)
Exemplo n.º 15
0
Arquivo: texi.py Projeto: 0004c/VTK
 def writeNodeData(self, node):
     latex.getLatexText(node, self.writer, texiEscape, entities)