pygments

Sphinx Pygments lexer filter extension?

南楼画角 提交于 2021-02-08 15:37:13
问题 I have a Lisp-like language I would like to highlight using Pygments in Sphinx code snippet documentation. My approach is to extend the existing CommonLispLexer to add the built-in names using a NameHighlightFilter. However, it is not working, so I must be missing something obvious. I have added the following to my conf.py: def setup(app): from sphinx.highlighting import lexers from pygments.lexers import CommonLispLexer from pygments.token import Name from pygments.filters import

LaTeX源代码列表,如专业书籍

流过昼夜 提交于 2020-03-14 20:42:20
乳胶源代码列表应如何生成类似于已知书籍的输出,例如Spring Framework的输出? 我尝试过使用乳胶列表包,但是无法生成看起来像下面那样漂亮的东西。 因此,我对格式化指令感兴趣,以生成类似下面的示例(来自Manning的 Spring in Action 示例章节 ): 编辑 在 TormodFjeldskår 的帮助下,这里有完整的片段,可以产生所需的外观: \usepackage{listings} \usepackage{courier} \lstset{ basicstyle=\footnotesize\ttfamily, % Default font % numbers=left, % Location of line numbers numberstyle=\tiny, % Style of line numbers % stepnumber=2, % Margin between line numbers numbersep=5pt, % Margin between line numbers and text tabsize=2, % Size of tabs extendedchars=true, breaklines=true, % Lines will be wrapped keywordstyle=\color{red}, frame=b, %

Highlight in html issue with Jekyll/Liquid and pygments

佐手、 提交于 2020-01-24 19:41:10
问题 I'm using Jekyll with pygments and having an issue using {% highlight %} in .html posts. As you can see here, it is just printing out {% highlight %} yet on my homepage the syntax highlighting works See here: iwasasuperhero. Here is the code for the index, and the code for the post: Here I'm not really sure the issue or why it is working on the index but not the post page. Any ideas? 回答1: It seems I have figured out my problem. I was using {{ page.content }} in my post.html instead of just {{

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

我是研究僧i 提交于 2019-12-20 10:56:00
问题 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? 回答1: as the editor

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

寵の児 提交于 2019-12-20 09:47:10
问题 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

Pygments syntax highlighting in Jekyll without starting a <div>

血红的双手。 提交于 2019-12-20 02:37:24
问题 If you use Jekyll with the Pygments syntax-highlighting package, it’s possible to write {% highlight clojure %} (def something :foobar) {% endhighlight %} which produces a <div> containing that line, syntax-highlighted according to Clojure syntax. But is there a way to get the syntax highlighting in the middle of a paragraph? I’d like to be able to write In Clojure, keywords like {% highlight clojure %}:foobar{% endhighlight %} are prepended by colons. The desired behavior here is that the

Showing file name in Jekyll with Pygments code highlight

ε祈祈猫儿з 提交于 2019-12-14 03:57:29
问题 When highlighting a standard file at a known location I'd like to put the file name in the code block; preferably at the top. A hypothetical example would be {% highlight apache show_filename=/etc/httpd/conf/httpd.conf %} .... the file contents .... {% endhighlight %} which would then render a code block with a filename prefixed. Is there a way to accomplish this? 回答1: You can simply use the nice html5 figure tag. " The HTML Element represents self-contained content, frequently with a caption

Getting Pygments to work for my cell results

给你一囗甜甜゛ 提交于 2019-12-12 15:10:07
问题 I use Jupyter Notebooks to implement and document changes that apply to our production databases. I program in Python and submit typical SQL statements to the server to fetch results and make changes. I like to print the sql as part of the cell output for verbose log of the change. I wanted pygments to help colorize the output so that the SQL would look as nice as possible. Seems that pygments uses css and I don't know how to get it included from pygments import highlight from pygments.lexers

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

怎甘沉沦 提交于 2019-12-12 07:36:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . 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

How do I change the highlight color style of the code in the IPython(Jupyter)?

丶灬走出姿态 提交于 2019-12-12 01:51:34
问题 My question is showed in the following picutre. I want to change the highlight color style of the code region that is specified by the red rectangle in the picutre below. But I dont' know which token I should change style of. My pygment style setting code is below from pygments.style import Style from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Whitespace, Token class EmacsStyle(Style): """ The default style (inspired by Emacs 22). """ background