pygments

How to use pygments with readline to colorize the input text according to the tokens?

元气小坏坏 提交于 2019-12-11 16:44:50
问题 I want to develop a Python theme which executes Python codes and which colorize the tokens in input() while users typing some text. Recently I have started to learn readline and pygments. I can add keyword tokens to the tab completion. Also i can colorize the stdout text with pygments highlight function. But still i can't colorize the tokens in input(). Is there anyone to give me an idea to do what i want? The codes below are from an example application. import readline from pygments.token

markdown display incorrect when add code block in list

半世苍凉 提交于 2019-12-11 12:24:14
问题 I am using pygments and kramdown in my jekyll blog. I tried to add code block to markdown list, but display incorrect. 1. first 2. second {% highlight ruby %} def foo puts 'foo' end {% endhighlight %} 3. third generated html: <ol> <li> <p>first</p> </li> <li> <p>second</p> </li> </ol> <div class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">foo</span> <span class="nb">puts</span> <span class="s1">'foo'</span> <span class="k">end<

run jekyll --server failed in win7

最后都变了- 提交于 2019-12-11 01:17:17
问题 when i run jekyll --server,it built failed ,and display this : [2013-01-10 15:34:52] regeneration: 1 files changed Liquid Exception: Failed to get header. in 2013-01-05-vim.markdown C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:357: in rescue in get_header' C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:338: in get_header' C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:235: in block in mentos' C:/Ruby193

Sphinx inline code highlight

旧时模样 提交于 2019-12-09 15:18:10
问题 I use Sphinx to make a website that contains code samples. I'm successful using the .. code-block directive to get syntax highlighting. But I can't get inline syntax highlighting using this code: .. role:: bash(code) :language: bash Test inline: :bash:`export FOO="bar"`. .. code-block:: bash export FOO="bar" which produces this output i.e. inline code not highlighted while block code is: Problem to me is that the generated HTML for inline code contains long class names while it does not for

Django - Did you forget to register or load this tag?

回眸只為那壹抹淺笑 提交于 2019-12-09 04:41:21
问题 I've created a custom tag that I want to use, but Django can't seem to find it. My templatetags directory is set up like this: pygmentize.py from pygments import highlight from pygments.lexers import get_lexer_by_name from django import template from pygments.formatters.other import NullFormatter register = template.Library() @register.tag(name='code') def do_code(parser,token): code = token.split_contents()[-1] nodelist = parser.parse(('endcode',)) parser.delete_first_token() return CodeNode

Tokenizer with Pygments in Python

大城市里の小女人 提交于 2019-12-08 07:50:58
问题 Want to create a tokenizer for source files (e.g. Java or C++) in Python. Came across Pygments and in particular these lexers. I could not found examples i the documentation and online for how to use the lexer. Wondering if it is possible to actually use Pygments in Python in order to get the tokens and their position for a given source file. I am struggling with the very basics here, so If someone could offer even a small chunk of code detailing the above it would be much appreciated. 回答1:

Sphinx inline code highlight

北城以北 提交于 2019-12-04 02:07:10
I use Sphinx to make a website that contains code samples. I'm successful using the .. code-block directive to get syntax highlighting. But I can't get inline syntax highlighting using this code: .. role:: bash(code) :language: bash Test inline: :bash:`export FOO="bar"`. .. code-block:: bash export FOO="bar" which produces this output i.e. inline code not highlighted while block code is: Problem to me is that the generated HTML for inline code contains long class names while it does not for code blocks. Here is the output HTML (indented for readability): <p>Test inline: <tt class="code bash

Extensive documentation on how to write a lexer for Pygments? [closed]

旧时模样 提交于 2019-12-03 06:31:40
I have a dictionary of Stata keywords and reasonable knowledge of Stata syntax. I would like to devote a few hours to turn it into a Stata lexer for Pygments . However, I cannot find enough documentation about the syntax of lexers and find myself unable to start coding the lexer. Could someone point out a good tutorial for writing new lexers for Pygments? I know about the Pygments API and the lexer development page , but honestly, these are not enough for someone like me with very limited knowledge of Python. My strategy so far has been to look for examples. I have found quite a few , e.g.

Utilizing emacs' or vim's syntax highlighter for command-line program?

社会主义新天地 提交于 2019-12-03 00:41:32
I have a command-line program that spews JSON and YAML. By default it detects if pygments (pygmentize) is available and if it does, pass the output throught it to get a nice colorized output. However, pygments is not installed by default on most computers that this program will run on. But most computers will have either emacs or vim, however, does. Is there a way to get one of these editors to syntax-highlight some text using ANSI escape sequences and then output it again? as the editor can already do the ansi stuff, rather easy to make a screen capture of the editor, no? script -qc "stty

Jekyll serve didn't work: It looks like you don't have pygments or one of its dependencies installed

自作多情 提交于 2019-12-02 18:47:13
Configuration file: /Users/andrechristoga/Documents/type-theme/_config.yml Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure you have `gems: [jekyll-paginate]` in your configuration file. Source: /Users/andrechristoga/Documents/type-theme Destination: /Users/andrechristoga/Documents/type-theme/_site Incremental build: disabled. Enable with --incremental Generating... Dependency Error: Yikes! It looks like you don't have pygments or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to