示例#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
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)