Skip to content
Snippets Groups Projects
Commit 95f75e19 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge tag 'v0.5.4' of https://github.com/tmm1/pygments.rb

parents 5358576d ddf8e122
No related branches found
No related tags found
No related merge requests found
Showing
with 616 additions and 43 deletions
changelog
===========
Version 0.5.4 (Nov 3, 2013)
-----------------------------
* Update lexers file
Version 0.5.3 (Sep 17, 2013)
-----------------------------
* Fixes for Slash lexer
* Improve highlighting for Slash lexer
* Upgrade to latest pygments (1.7, changes summary follows. See pygments changelog for details)
* Add Clay lexer
* Add Perl 6 lexer
* Add Swig lexer
* Add nesC lexer
* Add BlitzBasic lexer
* Add EBNF lexer
* Add Igor Pro lexer
* Add Rexx lexer
* Add Agda lexer
* Recognize vim modelines
* Improve Python 3 lexer
* Improve Opa lexer
* Improve Julia lexer
* Improve Lasso lexer
* Improve Objective C/C++ lexer
* Improve Ruby lexer
* Improve Stan lexer
* Improve JavaScript lexer
* Improve HTTP lexer
* Improve Koka lexer
* Improve Haxe lexer
* Improve Prolog lexer
* Improve F# lexer
Version 0.5.2 (July 17, 2013)
-----------------------------
* Add Slash lexer
Version 0.5.1 (June 25, 2013)
-----------------------------
* Ensure compatability across distros by detecting if `python2` is available
Version 0.5.0 (Apr 13, 2013)
-----------------------------
* Use #rstrip to fix table mode bug
Version 0.4.2 (Feb 25, 2013)
-----------------------------
* Add new lexers, including custom lexers
Version 0.3.7 (Jan 2, 2013)
-----------------------------
* Fixed missing custom lexers
* Added syntax highlighting for Hxml
Version 0.3.4 (Dec 28, 2012)
-----------------------------
* Add support for Windows
* Add MIT license
source :rubygems
source "https://rubygems.org"
gemspec
Loading
Loading
@@ -14,7 +14,8 @@ pygments.rb request.
 
## system requirements
 
- Python 2.5+
- Python 2.5, Python 2.6, or Python 2.7. You can always use Python 2.x from a `virtualenv` if
your default Python install is 3.x.
 
## usage
 
Loading
Loading
@@ -49,6 +50,12 @@ Pygments.css
Pygments.css('.highlight')
```
 
To use a specific pygments style, pass the `:style` option to the `#css` method:
``` ruby
Pygments.css(:style => "monokai")
```
Other Pygments high-level API methods are also available.
These methods return arrays detailing all the available lexers, formatters,
and styles.
Loading
Loading
@@ -66,6 +73,8 @@ To use a custom pygments installation, specify the path to
Pygments.start("/path/to/pygments")
```
 
If you'd like logging, set the environmental variable `MENTOS_LOG` to a file path for your logfile.
## benchmarks
 
 
Loading
Loading
@@ -87,5 +96,23 @@ Pygments.start("/path/to/pygments")
pygments popen (process already started) 0.010000 0.000000 0.010000 ( 0.676515)
pygments popen (process already started 2) 0.000000 0.010000 0.010000 ( 0.674189)
 
## license
The MIT License (MIT)
Copyright (c) Ted Nyman and Aman Gupta, 2012-2013
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading
Loading
@@ -9,9 +9,7 @@ task :default => :test
 
GEMSPEC = eval(File.read('pygments.rb.gemspec'))
 
require 'rake/gempackagetask'
Rake::GemPackageTask.new(GEMSPEC) do |pkg|
end
require 'rubygems/package_task'
 
# ==========================================================
# Testing
Loading
Loading
@@ -33,14 +31,13 @@ end
 
# ==========================================================
# Cache lexers
# # ==========================================================
# ==========================================================
 
# Write all the lexers to a file for easy lookup
task :lexers do
sh "ruby cache-lexers.rb"
end
 
# ==========================================================
# Vendor
# ==========================================================
Loading
Loading
No preview for this file type
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
 
import sys, re, os, signal, resource
import sys, re, os, signal
import traceback
if 'PYGMENTS_PATH' in os.environ:
sys.path.insert(0, os.environ['PYGMENTS_PATH'])
Loading
Loading
@@ -320,20 +320,27 @@ def main():
# Signal handlers to trap signals.
signal.signal(signal.SIGINT, _signal_handler)
signal.signal(signal.SIGTERM, _signal_handler)
signal.signal(signal.SIGHUP, _signal_handler)
if sys.platform != "win32":
signal.signal(signal.SIGHUP, _signal_handler)
 
mentos = Mentos()
 
# close fd's inherited from the ruby parent
maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if maxfd == resource.RLIM_INFINITY:
maxfd = 65536
for fd in range(3, maxfd):
try:
os.close(fd)
except:
pass
if sys.platform == "win32":
# disable CRLF
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
else:
# close fd's inherited from the ruby parent
import resource
maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if maxfd == resource.RLIM_INFINITY:
maxfd = 65536
for fd in range(3, maxfd):
try:
os.close(fd)
except:
pass
 
mentos.start()
 
Loading
Loading
Loading
Loading
@@ -20,12 +20,13 @@ module Pygments
# Python process that talks to the Pygments library. We'll talk back and
# forth across this pipe.
def start(pygments_path = File.expand_path('../../../vendor/pygments-main/', __FILE__))
is_windows = RUBY_PLATFORM =~ /mswin|mingw/
begin
@log = Logger.new(ENV['MENTOS_LOG'] ||= '/dev/null')
@log = Logger.new(ENV['MENTOS_LOG'] ||= is_windows ? 'NUL:' : '/dev/null')
@log.level = Logger::INFO
@log.datetime_format = "%Y-%m-%d %H:%M "
rescue
@log = Logger.new('/dev/null')
@log = Logger.new(is_windows ? 'NUL:' : '/dev/null')
end
 
ENV['PYGMENTS_PATH'] = pygments_path
Loading
Loading
@@ -35,10 +36,21 @@ module Pygments
 
# A pipe to the mentos python process. #popen4 gives us
# the pid and three IO objects to write and read.
@pid, @in, @out, @err = popen4(File.expand_path('../mentos.py', __FILE__))
script = "#{python_binary} #{File.expand_path('../mentos.py', __FILE__)}"
@pid, @in, @out, @err = popen4(script)
@log.info "[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}."
end
 
# Detect a suitable Python binary to use. We can't just use `python2`
# because apparently some old versions of Debian only have `python` or
# something like that.
def python_binary
@python_binary ||= begin
`which python2`
$?.success? ? "python2" : "python"
end
end
# Stop the child process by issuing a kill -9.
#
# We then call waitpid() with the pid, which waits for that particular
Loading
Loading
@@ -126,6 +138,10 @@ module Pygments
:filenames => lxr[2],
:mimetypes => lxr[3]
}
hash["Augeas"] = {:name=>"Augeas", :aliases=>["augeas"], :filenames=>["*.aug"], :mimetypes=>[]}
hash["dasm16"] = {:name=>"dasm16", :aliases=>["DASM16"], :filenames=>["*.dasm16", "*.dasm"], :mimetypes=>['text/x-dasm16']}
hash["Puppet"] = {:name=>"Puppet", :aliases=>["puppet"], :filenames=>["*.pp"], :mimetypes=>[]}
hash["Slash"] = {:name=>"Slash", :aliases=>["slash"], :filenames=>["*.sl"], :mimetypes=>[]}
hash
end
end
Loading
Loading
@@ -358,7 +374,8 @@ module Pygments
unless method == :lexer_name_for || method == :highlight || method == :css
res = Yajl.load(res, :symbolize_keys => true)
end
res = res[0..-2]
res = res.rstrip if res.class == String
res
end
 
# Convert a text header into JSON for easy access.
Loading
Loading
module Pygments
VERSION = '0.3.2'
VERSION = '0.5.4'
end
Loading
Loading
@@ -17,10 +17,22 @@ class PygmentsHighlightTest < Test::Unit::TestCase
assert_equal '<div class', code[0..9]
end
 
def test_full_html_highlight
code = P.highlight(RUBY_CODE)
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
assert_equal "<div class=\"highlight\"><pre><span class=\"c1\">#!/usr/bin/ruby</span>\n<span class=\"nb\">puts</span> <span class=\"s1\">&#39;foo&#39;</span>\n</pre></div>", code
end
def test_full_table_highlight
code = P.highlight(RUBY_CODE, :options => {:linenos => true})
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
assert_equal "<table class=\"highlighttable\"><tr><td class=\"linenos\"><div class=\"linenodiv\"><pre>1\n2</pre></div></td><td class=\"code\"><div class=\"highlight\"><pre><span class=\"c1\">#!/usr/bin/ruby</span>\n<span class=\"nb\">puts</span> <span class=\"s1\">&#39;foo&#39;</span>\n</pre></div>\n</td></tr></table>", code
end
def test_highlight_works_with_larger_files
code = P.highlight(REDIS_CODE)
assert_match 'used_memory_peak_human', code
assert_equal 454107, code.bytesize.to_i
assert_equal 455203, code.bytesize.to_i
end
 
def test_returns_nil_on_timeout
Loading
Loading
@@ -210,7 +222,6 @@ class PygmentsLexerClassTest < Test::Unit::TestCase
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.1')
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.3')
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.c')
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.h')
assert_equal P::Lexer['Python'], P::Lexer.find_by_extname('.py')
assert_equal P::Lexer['Java'], P::Lexer.find_by_extname('.java')
end
Loading
Loading
Loading
Loading
@@ -10,11 +10,12 @@
"""
import re
 
from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
using, DelegatingLexer
from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
Other, Keyword, Operator, Literal
Other, Keyword, Operator, Literal, Whitespace
 
__all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer']
__all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer', "TOMLLexer", "SlashLexer"]
 
class Dasm16Lexer(RegexLexer):
"""
Loading
Loading
@@ -360,3 +361,205 @@ class AugeasLexer(RegexLexer):
(r'[\*\)]', Comment.Multiline)
],
}
class TOMLLexer(RegexLexer):
"""
Lexer for TOML, a simple language for config files
"""
name = 'TOML'
aliases = ['toml']
filenames = ['*.toml']
tokens = {
'root': [
# Basics, comments, strings
(r'\s+', Text),
(r'#.*?$', Comment.Single),
(r'"(\\\\|\\"|[^"])*"', String),
(r'(true|false)$', Keyword.Constant),
('[a-zA-Z_][a-zA-Z0-9_\-]*', Name),
# Datetime
(r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z', Number.Integer),
# Numbers
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
(r'\d+[eE][+-]?[0-9]+j?', Number.Float),
(r'\-?\d+', Number.Integer),
# Punctuation
(r'[]{}:(),;[]', Punctuation),
(r'\.', Punctuation),
# Operators
(r'=', Operator)
]
}
class SlashLanguageLexer(ExtendedRegexLexer):
_nkw = r'(?=[^a-zA-Z_0-9])'
def move_state(new_state):
return ("#pop", new_state)
def right_angle_bracket(lexer, match, ctx):
if len(ctx.stack) > 1 and ctx.stack[-2] == "string":
ctx.stack.pop()
yield match.start(), String.Interpol, u"}"
ctx.pos = match.end()
pass
tokens = {
"root": [
(r"<%=", Comment.Preproc, move_state("slash")),
(r"<%!!", Comment.Preproc, move_state("slash")),
(r"<%#.*?%>", Comment.Multiline),
(r"<%", Comment.Preproc, move_state("slash")),
(r".|\n", Other),
],
"string": [
(r"\\", String.Escape, move_state("string_e")),
(r"\"", String, move_state("slash")),
(r"#\{", String.Interpol, "slash"),
(r'.|\n', String),
],
"string_e": [
(r'n', String.Escape, move_state("string")),
(r't', String.Escape, move_state("string")),
(r'r', String.Escape, move_state("string")),
(r'e', String.Escape, move_state("string")),
(r'x[a-fA-F0-9]{2}', String.Escape, move_state("string")),
(r'.', String.Escape, move_state("string")),
],
"regexp": [
(r'}[a-z]*', String.Regex, move_state("slash")),
(r'\\(.|\n)', String.Regex),
(r'{', String.Regex, "regexp_r"),
(r'.|\n', String.Regex),
],
"regexp_r": [
(r'}[a-z]*', String.Regex, "#pop"),
(r'\\(.|\n)', String.Regex),
(r'{', String.Regex, "regexp_r"),
],
"slash": [
(r"%>", Comment.Preproc, move_state("root")),
(r"\"", String, move_state("string")),
(r"'[a-zA-Z0-9_]+", String),
(r'%r{', String.Regex, move_state("regexp")),
(r'/\*.*?\*/', Comment.Multiline),
(r"(#|//).*?\n", Comment.Single),
(r'-?[0-9]+e[+-]?[0-9]+', Number.Float),
(r'-?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?', Number.Float),
(r'-?[0-9]+', Number.Integer),
(r'nil'+_nkw, Name.Builtin),
(r'true'+_nkw, Name.Builtin),
(r'false'+_nkw, Name.Builtin),
(r'self'+_nkw, Name.Builtin),
(r'(class)(\s+)([A-Z][a-zA-Z0-9_\']*)',
bygroups(Keyword, Whitespace, Name.Class)),
(r'class'+_nkw, Keyword),
(r'extends'+_nkw, Keyword),
(r'(def)(\s+)(self)(\s*)(\.)(\s*)([a-z_][a-zA-Z0-9_\']*=?|<<|>>|==|<=>|<=|<|>=|>|\+|-(self)?|~(self)?|\*|/|%|^|&&|&|\||\[\]=?)',
bygroups(Keyword, Whitespace, Name.Builtin, Whitespace, Punctuation, Whitespace, Name.Function)),
(r'(def)(\s+)([a-z_][a-zA-Z0-9_\']*=?|<<|>>|==|<=>|<=|<|>=|>|\+|-(self)?|~(self)?|\*|/|%|^|&&|&|\||\[\]=?)',
bygroups(Keyword, Whitespace, Name.Function)),
(r'def'+_nkw, Keyword),
(r'if'+_nkw, Keyword),
(r'elsif'+_nkw, Keyword),
(r'else'+_nkw, Keyword),
(r'unless'+_nkw, Keyword),
(r'for'+_nkw, Keyword),
(r'in'+_nkw, Keyword),
(r'while'+_nkw, Keyword),
(r'until'+_nkw, Keyword),
(r'and'+_nkw, Keyword),
(r'or'+_nkw, Keyword),
(r'not'+_nkw, Keyword),
(r'lambda'+_nkw, Keyword),
(r'try'+_nkw, Keyword),
(r'catch'+_nkw, Keyword),
(r'return'+_nkw, Keyword),
(r'next'+_nkw, Keyword),
(r'last'+_nkw, Keyword),
(r'throw'+_nkw, Keyword),
(r'use'+_nkw, Keyword),
(r'switch'+_nkw, Keyword),
(r'\\', Keyword),
(r'λ', Keyword),
(r'__FILE__'+_nkw, Name.Builtin.Pseudo),
(r'__LINE__'+_nkw, Name.Builtin.Pseudo),
(r'[A-Z][a-zA-Z0-9_\']*'+_nkw, Name.Constant),
(r'[a-z_][a-zA-Z0-9_\']*'+_nkw, Name),
(r'@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Instance),
(r'@@[a-z_][a-zA-Z0-9_\']*'+_nkw, Name.Variable.Class),
(r'\(', Punctuation),
(r'\)', Punctuation),
(r'\[', Punctuation),
(r'\]', Punctuation),
(r'\{', Punctuation),
(r'\}', right_angle_bracket),
(r';', Punctuation),
(r',', Punctuation),
(r'<<=', Operator),
(r'>>=', Operator),
(r'<<', Operator),
(r'>>', Operator),
(r'==', Operator),
(r'!=', Operator),
(r'=>', Operator),
(r'=', Operator),
(r'<=>', Operator),
(r'<=', Operator),
(r'>=', Operator),
(r'<', Operator),
(r'>', Operator),
(r'\+\+', Operator),
(r'\+=', Operator),
(r'-=', Operator),
(r'\*\*=', Operator),
(r'\*=', Operator),
(r'\*\*', Operator),
(r'\*', Operator),
(r'/=', Operator),
(r'\+', Operator),
(r'-', Operator),
(r'/', Operator),
(r'%=', Operator),
(r'%', Operator),
(r'^=', Operator),
(r'&&=', Operator),
(r'&=', Operator),
(r'&&', Operator),
(r'&', Operator),
(r'\|\|=', Operator),
(r'\|=', Operator),
(r'\|\|', Operator),
(r'\|', Operator),
(r'!', Operator),
(r'\.\.\.', Operator),
(r'\.\.', Operator),
(r'\.', Operator),
(r'::', Operator),
(r':', Operator),
(r'(\s|\n)+', Whitespace),
(r'[a-z_][a-zA-Z0-9_\']*', Name.Variable),
],
}
class SlashLexer(DelegatingLexer):
"""
Lexer for the Slash programming language.
"""
name = 'Slash'
aliases = ['slash']
filenames = ['*.sl']
def __init__(self, **options):
from pygments.lexers.web import HtmlLexer
super(SlashLexer, self).__init__(HtmlLexer, SlashLanguageLexer, **options)
Loading
Loading
@@ -6,13 +6,17 @@ Major developers are Tim Hatch <tim@timhatch.com> and Armin Ronacher
Other contributors, listed alphabetically, are:
 
* Sam Aaron -- Ioke lexer
* Kumar Appaiah -- Debian control lexer
* Ali Afshar -- image formatter
* Thomas Aglassinger -- Rexx lexer
* Kumar Appaiah -- Debian control lexer
* Andreas Amann -- AppleScript lexer
* Timothy Armstrong -- Dart lexer fixes
* Jeffrey Arnold -- R/S, Rd, BUGS, Jags, and Stan lexers
* Jeremy Ashkenas -- CoffeeScript lexer
* Stefan Matthias Aust -- Smalltalk lexer
* Ben Bangert -- Mako lexers
* Max Battcher -- Darcs patch lexer
* Tim Baumann -- (Literate) Agda lexer
* Paul Baumgart, 280 North, Inc. -- Objective-J lexer
* Michael Bayer -- Myghty lexers
* John Benediktsson -- Factor lexer
Loading
Loading
@@ -22,52 +26,78 @@ Other contributors, listed alphabetically, are:
* Frits van Bommel -- assembler lexers
* Pierre Bourdon -- bugfixes
* Hiram Chirino -- Scaml and Jade lexers
* Ian Cooper -- VGL lexer
* Leaf Corcoran -- MoonScript lexer
* Christian Jann -- ShellSession lexer
* Christopher Creutzig -- MuPAD lexer
* Pete Curry -- bugfixes
* Owen Durni -- haXe lexer
* Bryan Davis -- EBNF lexer
* Owen Durni -- Haxe lexer
* Nick Efford -- Python 3 lexer
* Sven Efftinge -- Xtend lexer
* Artem Egorkine -- terminal256 formatter
* James H. Fisher -- PostScript lexer
* William S. Fulton -- SWIG lexer
* Carlos Galdino -- Elixir and Elixir Console lexers
* Michael Galloy -- IDL lexer
* Naveen Garg -- Autohotkey lexer
* Laurent Gautier -- R/S lexer
* Alex Gaynor -- PyPy log lexer
* Richard Gerkin -- Igor Pro lexer
* Alain Gilbert -- TypeScript lexer
* Alex Gilding -- BlitzBasic lexer
* Bertrand Goetzmann -- Groovy lexer
* Krzysiek Goj -- Scala lexer
* Matt Good -- Genshi, Cheetah lexers
* Michał Górny -- vim modeline support
* Patrick Gotthardt -- PHP namespaces support
* Olivier Guibe -- Asymptote lexer
* Jordi Gutiérrez Hermoso -- Octave lexer
* Martin Harriman -- SNOBOL lexer
* Matthew Harrison -- SVG formatter
* Steven Hazel -- Tcl lexer
* Aslak Hellesøy -- Gherkin lexer
* Jordi Gutiérrez Hermoso -- Octave lexer
* Greg Hendershott -- Racket lexer
* David Hess, Fish Software, Inc. -- Objective-J lexer
* Varun Hiremath -- Debian control lexer
* Rob Hoelz -- Perl 6 lexer
* Doug Hogan -- Mscgen lexer
* Ben Hollis -- Mason lexer
* Dustin Howett -- Logos lexer
* Alastair Houghton -- Lexer inheritance facility
* Tim Howard -- BlitzMax lexer
* Ivan Inozemtsev -- Fantom lexer
* Brian R. Jackson -- Tea lexer
* Dennis Kaarsemaker -- sources.list lexer
* Igor Kalnitsky -- vhdl lexer
* Pekka Klärck -- Robot Framework lexer
* Eric Knibbe -- Lasso lexer
* Stepan Koltsov -- Clay lexer
* Adam Koprowski -- Opa lexer
* Benjamin Kowarsch -- Modula-2 lexer
* Alexander Kriegisch -- Kconfig and AspectJ lexers
* Marek Kubica -- Scheme lexer
* Jochen Kupperschmidt -- Markdown processor
* Gerd Kurzbach -- Modelica lexer
* Jon Larimer, Google Inc. -- Smali lexer
* Olov Lassus -- Dart lexer
* Sylvestre Ledru -- Scilab lexer
* Mark Lee -- Vala lexer
* Ben Mabey -- Gherkin lexer
* Angus MacArthur -- QML lexer
* Simone Margaritelli -- Hybris lexer
* Kirk McDonald -- D lexer
* Gordon McGregor -- SystemVerilog lexer
* Stephen McKamey -- Duel/JBST lexer
* Brian McKenna -- F# lexer
* Charles McLaughlin -- Puppet lexer
* Lukas Meuser -- BBCode formatter, Lua lexer
* Paul Miller -- LiveScript lexer
* Hong Minhee -- HTTP lexer
* Michael Mior -- Awk lexer
* Bruce Mitchener -- Dylan lexer rewrite
* Reuben Morais -- SourcePawn lexer
* Jon Morton -- Rust lexer
* Paulo Moura -- Logtalk lexer
* Mher Movsisyan -- DTD lexer
* Ana Nelson -- Ragel, ANTLR, R console lexers
Loading
Loading
@@ -76,11 +106,13 @@ Other contributors, listed alphabetically, are:
* Mike Nolta -- Julia lexer
* Jonas Obrist -- BBCode lexer
* David Oliva -- Rebol lexer
* Pat Pannuto -- nesC lexer
* Jon Parise -- Protocol buffers lexer
* Ronny Pfannschmidt -- BBCode lexer
* Benjamin Peterson -- Test suite refactoring
* Dominik Picheta -- Nimrod lexer
* Clément Prévost -- UrbiScript lexer
* Kashif Rasul -- CUDA lexer
* Justin Reidy -- MXML lexer
* Norman Richards -- JSON lexer
* Lubomir Rintel -- GoodData MAQL and CL lexers
Loading
Loading
@@ -92,17 +124,22 @@ Other contributors, listed alphabetically, are:
* Joe Schafer -- Ada lexer
* Ken Schutte -- Matlab lexers
* Tassilo Schweyer -- Io, MOOCode lexers
* Ted Shaw -- AutoIt lexer
* Joerg Sieker -- ABAP lexer
* Robert Simmons -- Standard ML lexer
* Kirill Simonov -- YAML lexer
* Alexander Smishlajev -- Visual FoxPro lexer
* Steve Spigarelli -- XQuery lexer
* Jerome St-Louis -- eC lexer
* James Strachan -- Kotlin lexer
* Tom Stuart -- Treetop lexer
* Tiberius Teng -- default style overhaul
* Jeremy Thurgood -- Erlang, Squid config lexers
* Brian Tiffin -- OpenCOBOL lexer
* Erick Tryzelaar -- Felix lexer
* Daniele Varrazzo -- PostgreSQL lexers
* Abe Voelker -- OpenEdge ABL lexer
* Pepijn de Vos -- HTML formatter CTags support
* Whitney Young -- ObjectiveC lexer
* Matthias Vallentin -- Bro lexer
* Nathan Weizenbaum -- Haml and Sass lexers
Loading
Loading
@@ -110,6 +147,7 @@ Other contributors, listed alphabetically, are:
* Nils Winter -- Smalltalk lexer
* Davy Wybiral -- Clojure lexer
* Diego Zamboni -- CFengine3 lexer
* Enrique Zamudio -- Ceylon lexer
* Alex Zimin -- Nemerle lexer
 
Many thanks for all contributions!
Loading
Loading
@@ -2,17 +2,144 @@ Pygments changelog
==================
 
Issue numbers refer to the tracker at
http://bitbucket.org/birkenfeld/pygments-main/issues.
<http://bitbucket.org/birkenfeld/pygments-main/issues>,
pull request numbers to the requests at
<http://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
Version 1.7
-----------
(under development)
- Lexers added:
* Clay (PR#184)
* Perl 6 (PR#181)
* Swig (PR#168)
* nesC (PR#166)
* BlitzBasic (PR#197)
* EBNF (PR#193)
* Igor Pro (PR#172)
* Rexx (PR#199)
* Agda and Literate Agda (PR#203)
- Pygments will now recognize "vim" modelines when guessing the lexer for
a file based on content (PR#118).
- The NameHighlightFilter now works with any Name.* token type (#790).
- Python 3 lexer: add new exceptions from PEP 3151.
- Opa lexer: add new keywords (PR#170).
- Julia lexer: add keywords and underscore-separated number
literals (PR#176).
- Lasso lexer: fix method highlighting, update builtins. Fix
guessing so that plain XML isn't always taken as Lasso (PR#163).
- Objective C/C++ lexers: allow "@" prefixing any expression (#871).
- Ruby lexer: fix lexing of Name::Space tokens (#860).
- Stan lexer: update for version 1.3.0 of the language (PR#162).
- JavaScript lexer: add the "yield" keyword (PR#196).
- HTTP lexer: support for PATCH method (PR#190).
- Koka lexer: update to newest language spec (PR#201).
- Haxe lexer: rewrite and support for Haxe 3 (PR#174).
- Prolog lexer: add different kinds of numeric literals (#864).
- F# lexer: rewrite with newest spec for F# 3.0 (#842).
 
Version 1.6
-----------
(in development)
(released Feb 3, 2013)
- Lexers added:
* Dylan console (PR#149)
* Logos (PR#150)
* Shell sessions (PR#158)
- Fix guessed lexers not receiving lexer options (#838).
- Fix unquoted HTML attribute lexing in Opa (#841).
- Fixes to the Dart lexer (PR#160).
Version 1.6rc1
--------------
(released Jan 9, 2013)
 
- Lexers added:
 
* AspectJ (PR#90)
* AutoIt (PR#122)
* BUGS-like languages (PR#89)
* Ceylon (PR#86)
* Croc (new name for MiniD)
* CUDA (PR#75)
* Dg (PR#116)
* IDL (PR#115)
* Jags (PR#89)
* Julia (PR#61)
* Kconfig (#711)
* Lasso (PR#95, PR#113)
* LiveScript (PR#84)
* Monkey (PR#117)
* Mscgen (PR#80)
* NSIS scripts (PR#136)
* OpenCOBOL (PR#72)
* QML (PR#123)
* Puppet (PR#133)
* Racket (PR#94)
* Rdoc (PR#99)
* Robot Framework (PR#137)
* RPM spec files (PR#124)
* Rust (PR#67)
* Smali (Dalvik assembly)
* SourcePawn (PR#39)
* Stan (PR#89)
* Treetop (PR#125)
* TypeScript (PR#114)
* VGL (PR#12)
* Visual FoxPro (#762)
* Windows Registry (#819)
* Xtend (PR#68)
- The HTML formatter now supports linking to tags using CTags files, when the
python-ctags package is installed (PR#87).
- The HTML formatter now has a "linespans" option that wraps every line in a
<span> tag with a specific id (PR#82).
- When deriving a lexer from another lexer with token definitions, definitions
for states not in the child lexer are now inherited. If you override a state
in the child lexer, an "inherit" keyword has been added to insert the base
state at that position (PR#141).
- The C family lexers now inherit token definitions from a common base class,
removing code duplication (PR#141).
- Use "colorama" on Windows for console color output (PR#142).
- Fix Template Haskell highlighting (PR#63).
- Fix some S/R lexer errors (PR#91).
- Fix a bug in the Prolog lexer with names that start with 'is' (#810).
- Rewrite Dylan lexer, add Dylan LID lexer (PR#147).
- Add a Java quickstart document (PR#146).
 
- Fix Template Haskell highlighting (PR#63)
- Add a "external/autopygmentize" file that can be used as .lessfilter (#802).
 
 
Version 1.5
Loading
Loading
@@ -182,7 +309,7 @@ Version 1.3
* Ada
* Coldfusion
* Modula-2
* haXe
* Haxe
* R console
* Objective-J
* Haml and Sass
Loading
Loading
@@ -241,7 +368,7 @@ Version 1.2
* CMake
* Ooc
* Coldfusion
* haXe
* Haxe
* R console
 
- Added options for rendering LaTeX in source code comments in the
Loading
Loading
Copyright (c) 2006-2011 by the respective authors (see AUTHORS file).
Copyright (c) 2006-2013 by the respective authors (see AUTHORS file).
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@
#
# Combines scripts for common tasks.
#
# :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
# :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
# :license: BSD, see LICENSE for details.
#
 
Loading
Loading
5cc94956e233
7304e4759ae6
Loading
Loading
@@ -6,7 +6,7 @@
 
Generates a bunch of html files containing the documentation.
 
:copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
 
Loading
Loading
Loading
Loading
@@ -64,7 +64,7 @@ def `guess_lexer(text, **options):`
def `guess_lexer_for_filename(filename, text, **options):`
As `guess_lexer()`, but only lexers which have a pattern in `filenames`
or `alias_filenames` that matches `filename` are taken into consideration.
`pygments.util.ClassNotFound` is raised if no lexer thinks it can handle the
content.
 
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ Welcome to the Pygments documentation.
- `Write your own lexer <lexerdevelopment.txt>`_
 
- `Write your own formatter <formatterdevelopment.txt>`_
- `Write your own filter <filterdevelopment.txt>`_
 
- `Register plugins <plugins.txt>`_
Loading
Loading
Loading
Loading
@@ -41,3 +41,8 @@ Bash completion
 
The source distribution contains a file ``external/pygments.bashcomp`` that
sets up completion for the ``pygmentize`` command in bash.
Java
----
See the `Java quickstart <java.txt>`_ document.
=====================
Use Pygments in Java
=====================
Thanks to `Jython <http://www.jython.org>`__ it is possible to use Pygments in
Java.
This page is a simple tutorial to get an idea of how this is working. You can
then look at the `Jython documentation <http://www.jython.org/docs/>`__ for more
advanced use.
Since version 1.5, Pygments is deployed on `Maven Central
<http://repo1.maven.org/maven2/org/pygments/pygments/>`__ as a JAR so is Jython
which makes it a lot easier to create the Java project.
Here is an example of a `Maven <http://www.maven.org>`__ ``pom.xml`` file for a
project running Pygments:
.. sourcecode:: xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>org.pygments</groupId>
<artifactId>pygments</artifactId>
<version>1.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
The following Java example:
.. sourcecode:: java
PythonInterpreter interpreter = new PythonInterpreter();
// Set a variable with the content you want to work with
interpreter.set("code", code);
// Simple use Pygments as you would in Python
interpreter.exec("from pygments import highlight\n"
+ "from pygments.lexers import PythonLexer\n"
+ "from pygments.formatters import HtmlFormatter\n"
+ "\nresult = highlight(code, PythonLexer(), HtmlFormatter())");
// Get the result that has been set in a variable
System.out.println(interpreter.get("result", String.class));
will print something like:
.. sourcecode:: html
<div class="highlight">
<pre><span class="k">print</span> <span class="s">&quot;Hello World&quot;</span></pre>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment