Ejemplo n.º 1
0
                pass
            elif ttype is Token.Generic.Strong:
                text = text.upper()
                pass
            pass

            outfile.write(text)
            pass
        return

    pass


rst_lex = RstLexer()
rst_filt = RstFilter()
rst_lex.add_filter(rst_filt)
color_tf = RSTTerminalFormatter(colorscheme=color_scheme)
mono_tf = MonoRSTTerminalFormatter()


def rst_text(text, mono, width=80):
    if mono:
        tf = mono_tf
    else:
        tf = color_tf
        pass
    tf.reset(width)
    return highlight(text, rst_lex, tf)


def syntax_highlight_file(input_filename,
Ejemplo n.º 2
0
                type
                text = "*%s*" % text
                pass            
            elif ttype is Token.Generic.Strong:
                text = text.upper()
                pass
            pass
            
            outfile.write(text)
            pass
        return
    pass

rst_lex = RstLexer()
rst_filt = RstFilter()
rst_lex.add_filter(rst_filt)
color_tf = RSTTerminalFormatter(colorscheme=color_scheme)
mono_tf  = MonoRSTTerminalFormatter()

def rst_text(text, mono, width=80):
    if mono:
        tf = mono_tf
    else:
        tf = color_tf
        pass
    tf.reset(width)
    return highlight(text, rst_lex, tf)

if __name__ == '__main__':

    def show_it(string, tf, width=80):
Ejemplo n.º 3
0
    def test_mono(self):

        # Could be in setup()
        rst_lex = RstLexer()
        rst_filt = Mformat.RstFilter()
        rst_lex.add_filter(rst_filt)
        rst_tf = Mformat.MonoRSTTerminalFormatter()
        text = '`A` very *emphasis* **strong** `code`'
        if sys.version_info[0:2] <= (3, 2):
            return
        got = Mformat.highlight(text, rst_lex, rst_tf)
        self.assertEqual('"A" very *emphasis* STRONG "code" ', got)

        self.maxDiff = 3000
        quit_text = """**quit** - gently terminate the debugged program.

The program being debugged is aborted via a *DebuggerQuit*
exception.

When the debugger from the outside (e.g. via a `trepan` command), the
debugged program is contained inside a try block which handles the
*DebuggerQuit* exception.  However if you called the debugger was
started in the middle of a program, there might not be such an
exception handler; the debugged program still terminates but generally
with a traceback showing that exception.

If the debugged program is threaded or worse threaded and deadlocked,
raising an exception in one thread isn't going to quit the
program. For this see `exit` or `kill` for more forceful termination
commands.

Also, see `run` and `restart` for other ways to restart the debugged
program.
"""
        rst_tf.reset(80)
        got = Mformat.highlight(quit_text, rst_lex, rst_tf)
        # FIXME: reinstate
        if False:
            self.assertEqual(
                """QUIT - gently terminate the debugged program.

The program being debugged is aborted via a *DebuggerQuit* exception.

When the debugger from the outside (e.g. via a "trepan" command), the debugged
program is contained inside a try block which handles the *DebuggerQuit*
exception. However if you called the debugger was started in the middle of a
program, there might not be such an exception handler; the debugged program
still terminates but generally with a traceback showing that exception.

If the debugged program is threaded or worse threaded and deadlocked, raising
an exception in one thread isn't going to quit the program. For this see "exit"
or "kill" for more forceful termination commands.

Also, see "run" and "restart" for other ways to restart the debugged program. """,
                got)

        text = '''
This is an example to show off *reformatting.*
We have several lines
here which should be reflowed.

But paragraphs should be respected.

    And verbatim
    text should not be
    touched

End of test.
'''
        rst_tf.reset(30)
        got = Mformat.highlight(text, rst_lex, rst_tf)
        # FIXME: reinstate
        if False:
            self.assertEqual(
                """This is an example to show
off *reformatting.* We have
several lines here which
should be reflowed.

But paragraphs should be
respected.

    And verbatim
    text should not be
    touched


End of test. """, got)

        return
Ejemplo n.º 4
0
    def test_mono(self):

        # Could be in setup()
        rst_lex  = RstLexer()
        rst_filt = Mformat.RstFilter()
        rst_lex.add_filter(rst_filt)
        rst_tf = Mformat.MonoRSTTerminalFormatter()
        text = '`A` very *emphasis* **strong** `code`'
        got = Mformat.highlight(text, rst_lex, rst_tf)
        self.assertEqual('"A" very *emphasis* STRONG "code" ', got)

        quit_text = """**quit** - gently terminate the debugged program.

The program being debugged is aborted via a *DebuggerQuit*
exception.

When the debugger from the outside (e.g. via a `trepan` command), the
debugged program is contained inside a try block which handles the
*DebuggerQuit* exception.  However if you called the debugger was
started in the middle of a program, there might not be such an
exception handler; the debugged program still terminates but generally
with a traceback showing that exception.

If the debugged program is threaded or worse threaded and deadlocked,
raising an exception in one thread isn't going to quit the
program. For this see `exit` or `kill` for more forceful termination
commands.

Also, see `run` and `restart` for other ways to restart the debugged
program.
"""
        rst_tf.reset(80)
        got = Mformat.highlight(quit_text, rst_lex, rst_tf)
        self.assertEqual("""QUIT - gently terminate the debugged program. 

The program being debugged is aborted via a *DebuggerQuit* exception. 

When the debugger from the outside (e.g. via a "trepan" command), the debugged 
program is contained inside a try block which handles the *DebuggerQuit* 
exception. However if you called the debugger was started in the middle of a 
program, there might not be such an exception handler; the debugged program 
still terminates but generally with a traceback showing that exception. 

If the debugged program is threaded or worse threaded and deadlocked, raising 
an exception in one thread isn't going to quit the program. For this see "exit"
or "kill" for more forceful termination commands. 

Also, see "run" and "restart" for other ways to restart the debugged program. """,
                         got)

        text ='''
This is an example to show off *reformatting.*
We have several lines
here which should be reflowed.

But paragraphs should be respected.

    And verbatim
    text should not be
    touched

End of test.
'''
        rst_tf.reset(30)
        got = Mformat.highlight(text, rst_lex, rst_tf)
        self.assertEqual(
        """This is an example to show 
off *reformatting.* We have 
several lines here which 
should be reflowed. 

But paragraphs should be 
respected. 

    And verbatim
    text should not be
    touched


End of test. """,
            got)

         
        return