Questions tagged [pygments]

A generic source code syntax highlighter written in Python.

Pygments is a generic source code syntax highlighter, written in , with support for a wide range of common languages and markup formats. Pygments is the standard syntax highlighter used by the Jekyll blogging platform.

264 questions
15
votes
2 answers

Pygments in QScintilla

Consider this mcve: import math import sys import textwrap import time from pathlib import Path from collections import defaultdict from PyQt5.Qsci import QsciLexerCustom, QsciScintilla from PyQt5.Qt import * from pygments import lexers, styles,…
BPL
  • 9,632
  • 9
  • 59
  • 117
15
votes
1 answer

How do I implement Rouge syntax highlighting in Rails?

There are a bunch of tutorials floating around, but they seem to be incomplete or not fully current or don't fully work for me. This is what I have done. Gemfile: gem 'rouge' gem 'redcarpet' Then I created a config/initializer/rouge.rb: require…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
15
votes
2 answers

How to reduce the separation from other text using LaTeX minted?

I want to use the minted package to give me syntax highlighting but it has a spacing of more than a…
cvandonderen
  • 153
  • 1
  • 4
14
votes
2 answers

Do I need to generate a css file from Pygments for my jekyll blog, to enable colorful code snippet?

This is my first time to use Jekyll and Pygments. But I don't know how to insert colorful code snippet. I successfully installed Pygments, following the official steps, with the markdown like this: {% highlight ruby %} def foo puts 'foo' end {%…
user1261841
  • 143
  • 1
  • 4
12
votes
5 answers

How to include pygments styles in a sphinx project?

Sphinx can define themes as well as a pygments style to use. I couldn't however - find a good way for a Sphinx project to define a custom style (color scheme) for pygments to use. From the docs: To make the style usable for Pygments, you…
ideasman42
  • 42,413
  • 44
  • 197
  • 320
10
votes
1 answer

Python pygments lexer state preservation

Running pygments default lexer on the following c++ text: class foo{};, results in this: (Token.Keyword, 'class') (Token.Text, ' ') (Token.Name.Class, 'foo') (Token.Punctuation, '{') (Token.Punctuation, '}') (Token.Punctuation, ';') Note that the…
Raxvan
  • 6,257
  • 2
  • 25
  • 46
10
votes
5 answers

Parsing a document with BeautifulSoup while not-parsing the contents of tags

I'm writing a blog app with Django. I want to enable comment writers to use some tags (like , a, et cetera) but disable all others. In addition, I want to let them put code in tags, and have pygments parse them. For example, someone…
Dor
  • 902
  • 4
  • 24
10
votes
4 answers

How do I get in-line code with Jekyll and Pygments?

I'm using Markdown with Liquid tags to mark up some code for a Jekyll-generated site and would like to include some code that is both in-line (in a paragraph) and has coloured syntax (with Pygments), but it does not appear to work. The markup Lorem…
lucasrizoli
  • 628
  • 6
  • 14
10
votes
2 answers

Extensive documentation on how to write a lexer for Pygments?

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…
Fr.
  • 2,865
  • 2
  • 24
  • 44
9
votes
2 answers

Hugo + Pygments—How to change highlighting theme?

Using Pygments with Hugo, I can do syntax highlighting with blocks like this: ```ruby def hello object puts "Hello, #{object}" end ``` This "works" in that the code is colored, but the colors aren't good, with white text (from Pygments) on white…
Mirror318
  • 11,875
  • 14
  • 64
  • 106
9
votes
1 answer

Simple CSV lexer

I want to color CSV files with pygments by column like here: See that same column is colored with the same color. Currently pygments doesn't include CSV parser because CSV is said to be obscure format. So I tried to write a minimal one myself.…
Adobe
  • 12,967
  • 10
  • 85
  • 126
9
votes
2 answers

Is there a way in Sphinx/Pygments to emphasize one or more lines of code in literal includes?

In some sphinx docs I am writing, I am including code samples from an ancillary file like so: .. literalinclude:: mymodule.py :pyobject: MyClass :linenos: This particular doc is a tutorial, where the classes are build up step by step. What I…
Casey Duncan
  • 241
  • 2
  • 4
9
votes
2 answers

How can I keep Jekyll from adding whitespace in highlight?

I'm currently experimenting with Jekyll. Most things look fine, but the way Jekyll processes code highlighting seems to be buggy. I use pygments. Then Jekyll seems to use pieces like: {% highlight python %} #!/usr/bin/env python def wer(r, h): …
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
9
votes
2 answers

Jekyll Pygments Processing

I have been fighting with Jekyll and Pygments highlighting for a while now. I have pygments installed and have generated the css file, however when I run Jekyll to generate the site, the code highlighting does not appear to generate properly. Here…
Joseph Crawford
  • 1,470
  • 1
  • 15
  • 29
8
votes
3 answers

Sphinx documentation and hover text

Is it possible, using sphinx, to have hover-boxes for words that appear inside code snippets, similar to what the hover-boxes in the code samples in the angular.js landing page look and behave like?
matanster
  • 15,072
  • 19
  • 88
  • 167
1
2
3
17 18