Pages tagged as ‘pygments’

Pygments 0.9 – Herbstzeitlose Released

October 14th, 2007

The new version of Pygments is out now. The changelog is once again quite long and a couple of new lexers were added:

  • Erlang
  • ActionScript
  • Literate Haskell
  • Common Lisp
  • Various assembly languages
  • Gettext catalogs
  • Squid configuration
  • Debian control files
  • MySQL-style SQL
  • MOOCode

Some old lexers got updates too:

  • Greatly improved the Haskell and OCaml lexers.
  • Improved the Bash lexer’s handling of nested constructs.
  • The C# and Java lexers exhibited abysmal performance with some input code; this should now be fixed.
  • The IRC logs lexer is now able to colorize weechat logs too.
  • The Lua lexer now recognizes multi-line comments.
  • Fixed bugs in the D and MiniD lexer.

There are also two new formatters. One that outputs SVG documents and a terminal formatter that uses 256 different colors if the terminals support that. There is also a new style which resembles the vim7 default style.

For the full list of changes have a look at the changelog. You can download pygments from the download page. Happy coloring!

Pygments 0.8 Maikäfer Released

May 30th, 2007

The new version of Pygments 0.8 aka Maikäfter is out now. Changes in this release:

  • Lexers added:
    • Haskell, thanks to Adam Blinkinsop
    • Redcode, thanks to Adam Blinkinsop
    • D, thanks to Kirk McDonald
    • MuPad, thanks to Christopher Creutzig
    • MiniD, thanks to Jarrett Billingsley
    • Vim Script, by Tim Hatch
  • The HTML formatter now has a second line-numbers mode in which it will just integrate the numbers in the same <pre> tag as the code.
  • The CSharpLexer now is Unicode-aware, which means that it has an option that can be set so that it correctly lexes Unicode identifiers allowed by the C# specs.
  • Added a RaiseOnErrorTokenFilter that raises an exception when the lexer generates an error token, and a VisibleWhitespaceFilter that converts whitespace (spaces, tabs, newlines) into visible characters.
  • Fixed the do_insertions() helper function to yield correct indices.
  • The ReST lexer now automatically highlights source code blocks in .. sourcecode:: language and .. code:: language directive blocks.
  • Improved the default style (thanks to Tiberius Teng). The old default is still available as the "emacs" style (which was an alias before).
  • The get_style_defs method of HTML formatters now uses the cssclass option as the default selector if it was given.
  • Improved the ReST and Bash lexers a bit.
  • and again improved highlighting and fixed some bugs

Get it while it’s hot from the cheeseshop.

Pygments in Wordpress

May 30th, 2007

I wanted to have pygments support in wordpress and so I hacked up a small wordpress plugin that enables pygments support in wordpress. Because I was lazy and PHP sucks like hell I just supported the case of a php.ini with magic slashes disabled. Somehow wordpress reinserts some of those annoying things automatically in some places though.

If you want to try it out: pygments.php. Note that I do not support it, it’s released under the BSD license like Pygments itself, it requires an installed pygments with the pygmentize script, no idea which PHP version, disabled magic quotes I guess and that you generate a pygments.css file yourself that matches the style defined in the plugin.

It caches in the text, and has few overhead on rendering Basically all you have to do is typing <pre lang="LANGUAGE">code</pre> instead of using a normal pre tag. Escaping happens automatically.

Example:

# Server: ruby p2p.rb password server server-uri merge-servers
# Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337
# Client: ruby p2p.rb password client server-uri download-pattern
# Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb
require'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[/[^|].*/])[-1
]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M=="client"&&c(U).f(
x(U)).each{|n|p,c=x(n),c(n);(c.f(p,O[0],0).map{|f|s f}-D["*"]).each{|f|F.open(f,
"w"){|o|o<<c.f(p,f,1)}}}||(DRb.start_service U,C.new{def f(c,a=[],t=2)c==x(U)&&(
t==0&&D[s(a)]||t==1&&F.read(s(a))||p(a))end;def y()(p(U)+p).each{|u|c(u).f(x(u),
p(U))rescue()};self;end;private;def p(x=[]);O.push(*x).uniq!;O;end}.new.y;sleep)

Pygments GTK Rendering

May 30th, 2007

I found in Pete Savage’s blog and entry about using GtkSourceView in pygtk. The new version of GtkSourceView absolutely rocks, the old one does not because the ruby highlighter and more complex stuff simply does not work because the library is somewhat limited.

As a proof of concept I tried to integrate pygments into a pygtk window and it worked :-) Of course it doesn’t allow realtime updating thus it’s impossible to use it as editor component (at least for now) but it makes a good source view.

You can find the sources here: gtkpygments.py

cogitations driven by wordpress