Python pygments.lexers.Python3Lexer() Examples
The following are 9
code examples of pygments.lexers.Python3Lexer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygments.lexers
, or try the search function
.
Example #1
Source File: style_transfer.py From style_transfer with MIT License | 6 votes |
def printargs(): """Prints out all command-line parameters.""" switch = {BGColor.LIGHT: 'xcode', BGColor.DARK: 'vim', BGColor.UNKNOWN: 'default'} style = switch[terminal_bg()] pprint = print try: import pygments from pygments.lexers import Python3Lexer from pygments.formatters import Terminal256Formatter pprint = partial(pygments.highlight, lexer=Python3Lexer(), formatter=Terminal256Formatter(style=style), outfile=sys.stdout) except ImportError: pass print('Parameters:') for key in sorted(ARGS): v = repr(getattr(ARGS, key)) print('% 16s: ' % key, end='') pprint(v) print()
Example #2
Source File: tokenizer.py From PyObfx with GNU General Public License v3.0 | 5 votes |
def __init__(self, data): # Logger self.logger = Log() # Max ID self.max_id = 10 * 10 * 10 # Get tokens self.logger.log('Getting tokens from file...') self._tokens = list(Python3Lexer().get_tokens(data)) # Tokenize self._tokenize() # Get token by id
Example #3
Source File: pygments_highlighter.py From pySINDy with MIT License | 5 votes |
def __init__(self, parent, lexer=None): super(PygmentsHighlighter, self).__init__(parent) self._document = self.document() self._formatter = HtmlFormatter(nowrap=True) self.set_style('default') if lexer is not None: self._lexer = lexer else: if PY3: self._lexer = Python3Lexer() else: self._lexer = PythonLexer()
Example #4
Source File: test_python.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def lexer3(): yield Python3Lexer()
Example #5
Source File: test_terminal_formatter.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_others_work(): """Check other formatters don't crash.""" highlight(CODE, Python3Lexer(), LatexFormatter(style=MyStyle)) highlight(CODE, Python3Lexer(), HtmlFormatter(style=MyStyle))
Example #6
Source File: test_terminal_formatter.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_256esc_seq(): """ Test that a few escape sequences are actually used when using ansi<> color codes. """ def termtest(x): return highlight(x, Python3Lexer(), Terminal256Formatter(style=MyStyle)) assert '32;101' in termtest('0x123') assert '92;42' in termtest('123') assert '90' in termtest('#comment') assert '94;41' in termtest('"String"')
Example #7
Source File: __init__.py From schedula with European Union Public License 1.1 | 5 votes |
def render(self, *args, **kwargs): from pygments import highlight from pygments.lexers import Python3Lexer from pygments.formatters import HtmlFormatter code = render_output(self.item, self.pprint.pformat) formatter = HtmlFormatter(noclasses=True) formatter.style.background_color = 'transparent' return _format_output(highlight(code, Python3Lexer(), formatter))
Example #8
Source File: pygments_highlighter.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, parent, lexer=None): super(PygmentsHighlighter, self).__init__(parent) self._document = self.document() self._formatter = HtmlFormatter(nowrap=True) self.set_style('default') if lexer is not None: self._lexer = lexer else: if PY3: self._lexer = Python3Lexer() else: self._lexer = PythonLexer()
Example #9
Source File: pygments_highlighter.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, parent, lexer=None): super(PygmentsHighlighter, self).__init__(parent) self._document = self.document() self._formatter = HtmlFormatter(nowrap=True) self.set_style('default') if lexer is not None: self._lexer = lexer else: if PY3: self._lexer = Python3Lexer() else: self._lexer = PythonLexer()