pygments.rb 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +9 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lexers +0 -0
- data/lib/pygments/version.rb +1 -1
- data/test/test_pygments.rb +0 -1
- data/vendor/pygments-main/AUTHORS +14 -1
- data/vendor/pygments-main/CHANGES +56 -6
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/Makefile +1 -1
- data/vendor/pygments-main/REVISION +1 -0
- data/vendor/pygments-main/docs/generate.py +1 -1
- data/vendor/pygments-main/docs/src/api.txt +1 -1
- data/vendor/pygments-main/docs/src/index.txt +1 -1
- data/vendor/pygments-main/docs/src/integrate.txt +5 -0
- data/vendor/pygments-main/docs/src/java.txt +70 -0
- data/vendor/pygments-main/external/autopygmentize +64 -0
- data/vendor/pygments-main/external/markdown-processor.py +2 -2
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive-old.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +1 -1
- data/vendor/pygments-main/pygments/__init__.py +2 -2
- data/vendor/pygments-main/pygments/cmdline.py +14 -6
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +1 -1
- data/vendor/pygments-main/pygments/formatter.py +1 -1
- data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
- data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -1
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +73 -2
- data/vendor/pygments-main/pygments/formatters/img.py +1 -1
- data/vendor/pygments-main/pygments/formatters/latex.py +1 -1
- data/vendor/pygments-main/pygments/formatters/other.py +1 -1
- data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
- data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
- data/vendor/pygments-main/pygments/lexer.py +76 -12
- data/vendor/pygments-main/pygments/lexers/__init__.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +4 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_mapping.py +26 -10
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +11 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -2
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +14 -3
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +6 -6
- data/vendor/pygments-main/pygments/lexers/agile.py +6 -4
- data/vendor/pygments-main/pygments/lexers/asm.py +40 -2
- data/vendor/pygments-main/pygments/lexers/compiled.py +751 -438
- data/vendor/pygments-main/pygments/lexers/dalvik.py +2 -2
- data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +6 -5
- data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
- data/vendor/pygments-main/pygments/lexers/jvm.py +130 -16
- data/vendor/pygments-main/pygments/lexers/math.py +250 -9
- data/vendor/pygments-main/pygments/lexers/other.py +518 -13
- data/vendor/pygments-main/pygments/lexers/parsers.py +3 -2
- data/vendor/pygments-main/pygments/lexers/shell.py +48 -2
- data/vendor/pygments-main/pygments/lexers/special.py +1 -1
- data/vendor/pygments-main/pygments/lexers/sql.py +1 -1
- data/vendor/pygments-main/pygments/lexers/templates.py +7 -6
- data/vendor/pygments-main/pygments/lexers/text.py +9 -9
- data/vendor/pygments-main/pygments/lexers/web.py +264 -51
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/style.py +1 -1
- data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/token.py +1 -1
- data/vendor/pygments-main/pygments/unistring.py +1 -1
- data/vendor/pygments-main/pygments/util.py +1 -1
- data/vendor/pygments-main/scripts/check_sources.py +2 -2
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
- data/vendor/pygments-main/scripts/find_codetags.py +1 -1
- data/vendor/pygments-main/scripts/find_error.py +5 -6
- data/vendor/pygments-main/setup.cfg +1 -0
- data/vendor/pygments-main/setup.py +6 -4
- data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
- data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
- data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
- data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +2 -2
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
- data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +191 -701
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
- data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
- data/vendor/pygments-main/tests/old_run.py +1 -1
- data/vendor/pygments-main/tests/run.py +3 -2
- data/vendor/pygments-main/tests/support/tags +36 -0
- data/vendor/pygments-main/tests/test_basic_api.py +3 -2
- data/vendor/pygments-main/tests/test_clexer.py +1 -1
- data/vendor/pygments-main/tests/test_cmdline.py +1 -1
- data/vendor/pygments-main/tests/test_examplefiles.py +1 -1
- data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
- data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
- data/vendor/pygments-main/tests/test_token.py +1 -1
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +5 -4
- metadata +26 -2
data/CHANGELOG
ADDED
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
|
-
Copyright (c) Ted Nyman and Aman Gupta, 2012
|
|
2
|
+
Copyright (c) Ted Nyman and Aman Gupta, 2012-2013
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
5
5
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
data/README.md
CHANGED
|
@@ -92,7 +92,7 @@ Pygments.start("/path/to/pygments")
|
|
|
92
92
|
|
|
93
93
|
The MIT License (MIT)
|
|
94
94
|
|
|
95
|
-
Copyright (c) Ted Nyman and Aman Gupta, 2012
|
|
95
|
+
Copyright (c) Ted Nyman and Aman Gupta, 2012-2013
|
|
96
96
|
|
|
97
97
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
98
98
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
data/lexers
CHANGED
|
Binary file
|
data/lib/pygments/version.rb
CHANGED
data/test/test_pygments.rb
CHANGED
|
@@ -210,7 +210,6 @@ class PygmentsLexerClassTest < Test::Unit::TestCase
|
|
|
210
210
|
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.1')
|
|
211
211
|
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.3')
|
|
212
212
|
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.c')
|
|
213
|
-
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.h')
|
|
214
213
|
assert_equal P::Lexer['Python'], P::Lexer.find_by_extname('.py')
|
|
215
214
|
assert_equal P::Lexer['Java'], P::Lexer.find_by_extname('.java')
|
|
216
215
|
end
|
|
@@ -9,6 +9,7 @@ Other contributors, listed alphabetically, are:
|
|
|
9
9
|
* Kumar Appaiah -- Debian control lexer
|
|
10
10
|
* Ali Afshar -- image formatter
|
|
11
11
|
* Andreas Amann -- AppleScript lexer
|
|
12
|
+
* Timothy Armstrong -- Dart lexer fixes
|
|
12
13
|
* Jeffrey Arnold -- R/S, Rd, BUGS, Jags, and Stan lexers
|
|
13
14
|
* Jeremy Ashkenas -- CoffeeScript lexer
|
|
14
15
|
* Stefan Matthias Aust -- Smalltalk lexer
|
|
@@ -25,6 +26,7 @@ Other contributors, listed alphabetically, are:
|
|
|
25
26
|
* Hiram Chirino -- Scaml and Jade lexers
|
|
26
27
|
* Ian Cooper -- VGL lexer
|
|
27
28
|
* Leaf Corcoran -- MoonScript lexer
|
|
29
|
+
* Christian Jann -- ShellSession lexer
|
|
28
30
|
* Christopher Creutzig -- MuPAD lexer
|
|
29
31
|
* Pete Curry -- bugfixes
|
|
30
32
|
* Owen Durni -- haXe lexer
|
|
@@ -33,24 +35,28 @@ Other contributors, listed alphabetically, are:
|
|
|
33
35
|
* Artem Egorkine -- terminal256 formatter
|
|
34
36
|
* James H. Fisher -- PostScript lexer
|
|
35
37
|
* Carlos Galdino -- Elixir and Elixir Console lexers
|
|
38
|
+
* Michael Galloy -- IDL lexer
|
|
36
39
|
* Naveen Garg -- Autohotkey lexer
|
|
37
40
|
* Laurent Gautier -- R/S lexer
|
|
38
41
|
* Alex Gaynor -- PyPy log lexer
|
|
42
|
+
* Alain Gilbert -- TypeScript lexer
|
|
39
43
|
* Bertrand Goetzmann -- Groovy lexer
|
|
40
44
|
* Krzysiek Goj -- Scala lexer
|
|
41
45
|
* Matt Good -- Genshi, Cheetah lexers
|
|
42
46
|
* Patrick Gotthardt -- PHP namespaces support
|
|
43
47
|
* Olivier Guibe -- Asymptote lexer
|
|
48
|
+
* Jordi Gutiérrez Hermoso -- Octave lexer
|
|
44
49
|
* Martin Harriman -- SNOBOL lexer
|
|
45
50
|
* Matthew Harrison -- SVG formatter
|
|
46
51
|
* Steven Hazel -- Tcl lexer
|
|
47
52
|
* Aslak Hellesøy -- Gherkin lexer
|
|
48
53
|
* Greg Hendershott -- Racket lexer
|
|
49
|
-
* Jordi Gutiérrez Hermoso -- Octave lexer
|
|
50
54
|
* David Hess, Fish Software, Inc. -- Objective-J lexer
|
|
51
55
|
* Varun Hiremath -- Debian control lexer
|
|
52
56
|
* Doug Hogan -- Mscgen lexer
|
|
53
57
|
* Ben Hollis -- Mason lexer
|
|
58
|
+
* Dustin Howett -- Logos lexer
|
|
59
|
+
* Alastair Houghton -- Lexer inheritance facility
|
|
54
60
|
* Tim Howard -- BlitzMax lexer
|
|
55
61
|
* Ivan Inozemtsev -- Fantom lexer
|
|
56
62
|
* Brian R. Jackson -- Tea lexer
|
|
@@ -69,15 +75,18 @@ Other contributors, listed alphabetically, are:
|
|
|
69
75
|
* Sylvestre Ledru -- Scilab lexer
|
|
70
76
|
* Mark Lee -- Vala lexer
|
|
71
77
|
* Ben Mabey -- Gherkin lexer
|
|
78
|
+
* Angus MacArthur -- QML lexer
|
|
72
79
|
* Simone Margaritelli -- Hybris lexer
|
|
73
80
|
* Kirk McDonald -- D lexer
|
|
74
81
|
* Gordon McGregor -- SystemVerilog lexer
|
|
75
82
|
* Stephen McKamey -- Duel/JBST lexer
|
|
76
83
|
* Brian McKenna -- F# lexer
|
|
84
|
+
* Charles McLaughlin -- Puppet lexer
|
|
77
85
|
* Lukas Meuser -- BBCode formatter, Lua lexer
|
|
78
86
|
* Paul Miller -- LiveScript lexer
|
|
79
87
|
* Hong Minhee -- HTTP lexer
|
|
80
88
|
* Michael Mior -- Awk lexer
|
|
89
|
+
* Bruce Mitchener -- Dylan lexer rewrite
|
|
81
90
|
* Reuben Morais -- SourcePawn lexer
|
|
82
91
|
* Jon Morton -- Rust lexer
|
|
83
92
|
* Paulo Moura -- Logtalk lexer
|
|
@@ -105,18 +114,22 @@ Other contributors, listed alphabetically, are:
|
|
|
105
114
|
* Joe Schafer -- Ada lexer
|
|
106
115
|
* Ken Schutte -- Matlab lexers
|
|
107
116
|
* Tassilo Schweyer -- Io, MOOCode lexers
|
|
117
|
+
* Ted Shaw -- AutoIt lexer
|
|
108
118
|
* Joerg Sieker -- ABAP lexer
|
|
109
119
|
* Robert Simmons -- Standard ML lexer
|
|
110
120
|
* Kirill Simonov -- YAML lexer
|
|
121
|
+
* Alexander Smishlajev -- Visual FoxPro lexer
|
|
111
122
|
* Steve Spigarelli -- XQuery lexer
|
|
112
123
|
* Jerome St-Louis -- eC lexer
|
|
113
124
|
* James Strachan -- Kotlin lexer
|
|
114
125
|
* Tom Stuart -- Treetop lexer
|
|
115
126
|
* Tiberius Teng -- default style overhaul
|
|
116
127
|
* Jeremy Thurgood -- Erlang, Squid config lexers
|
|
128
|
+
* Brian Tiffin -- OpenCOBOL lexer
|
|
117
129
|
* Erick Tryzelaar -- Felix lexer
|
|
118
130
|
* Daniele Varrazzo -- PostgreSQL lexers
|
|
119
131
|
* Abe Voelker -- OpenEdge ABL lexer
|
|
132
|
+
* Pepijn de Vos -- HTML formatter CTags support
|
|
120
133
|
* Whitney Young -- ObjectiveC lexer
|
|
121
134
|
* Matthias Vallentin -- Bro lexer
|
|
122
135
|
* Nathan Weizenbaum -- Haml and Sass lexers
|
|
@@ -2,44 +2,94 @@ Pygments changelog
|
|
|
2
2
|
==================
|
|
3
3
|
|
|
4
4
|
Issue numbers refer to the tracker at
|
|
5
|
-
http://bitbucket.org/birkenfeld/pygments-main/issues
|
|
5
|
+
<http://bitbucket.org/birkenfeld/pygments-main/issues>,
|
|
6
|
+
pull request numbers to the requests at
|
|
7
|
+
<http://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
|
|
6
8
|
|
|
7
9
|
Version 1.6
|
|
8
10
|
-----------
|
|
9
|
-
(
|
|
11
|
+
(released Feb 3, 2013)
|
|
12
|
+
|
|
13
|
+
- Lexers added:
|
|
14
|
+
|
|
15
|
+
* Dylan console (PR#149)
|
|
16
|
+
* Logos (PR#150)
|
|
17
|
+
* Shell sessions (PR#158)
|
|
18
|
+
|
|
19
|
+
- Fix guessed lexers not receiving lexer options (#838).
|
|
20
|
+
|
|
21
|
+
- Fix unquoted HTML attribute lexing in Opa (#841).
|
|
22
|
+
|
|
23
|
+
- Fixes to the Dart lexer (PR#160).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Version 1.6rc1
|
|
27
|
+
--------------
|
|
28
|
+
(released Jan 9, 2013)
|
|
10
29
|
|
|
11
30
|
- Lexers added:
|
|
12
31
|
|
|
13
32
|
* AspectJ (PR#90)
|
|
33
|
+
* AutoIt (PR#122)
|
|
14
34
|
* BUGS-like languages (PR#89)
|
|
15
35
|
* Ceylon (PR#86)
|
|
16
36
|
* Croc (new name for MiniD)
|
|
17
37
|
* CUDA (PR#75)
|
|
18
38
|
* Dg (PR#116)
|
|
39
|
+
* IDL (PR#115)
|
|
19
40
|
* Jags (PR#89)
|
|
20
41
|
* Julia (PR#61)
|
|
21
42
|
* Kconfig (#711)
|
|
22
|
-
* Lasso (PR#95)
|
|
43
|
+
* Lasso (PR#95, PR#113)
|
|
23
44
|
* LiveScript (PR#84)
|
|
24
45
|
* Monkey (PR#117)
|
|
25
46
|
* Mscgen (PR#80)
|
|
47
|
+
* NSIS scripts (PR#136)
|
|
48
|
+
* OpenCOBOL (PR#72)
|
|
49
|
+
* QML (PR#123)
|
|
50
|
+
* Puppet (PR#133)
|
|
26
51
|
* Racket (PR#94)
|
|
27
52
|
* Rdoc (PR#99)
|
|
28
53
|
* Robot Framework (PR#137)
|
|
54
|
+
* RPM spec files (PR#124)
|
|
29
55
|
* Rust (PR#67)
|
|
30
56
|
* Smali (Dalvik assembly)
|
|
31
57
|
* SourcePawn (PR#39)
|
|
32
58
|
* Stan (PR#89)
|
|
33
59
|
* Treetop (PR#125)
|
|
60
|
+
* TypeScript (PR#114)
|
|
34
61
|
* VGL (PR#12)
|
|
62
|
+
* Visual FoxPro (#762)
|
|
35
63
|
* Windows Registry (#819)
|
|
36
64
|
* Xtend (PR#68)
|
|
37
65
|
|
|
38
|
-
-
|
|
66
|
+
- The HTML formatter now supports linking to tags using CTags files, when the
|
|
67
|
+
python-ctags package is installed (PR#87).
|
|
68
|
+
|
|
69
|
+
- The HTML formatter now has a "linespans" option that wraps every line in a
|
|
70
|
+
<span> tag with a specific id (PR#82).
|
|
71
|
+
|
|
72
|
+
- When deriving a lexer from another lexer with token definitions, definitions
|
|
73
|
+
for states not in the child lexer are now inherited. If you override a state
|
|
74
|
+
in the child lexer, an "inherit" keyword has been added to insert the base
|
|
75
|
+
state at that position (PR#141).
|
|
76
|
+
|
|
77
|
+
- The C family lexers now inherit token definitions from a common base class,
|
|
78
|
+
removing code duplication (PR#141).
|
|
79
|
+
|
|
80
|
+
- Use "colorama" on Windows for console color output (PR#142).
|
|
81
|
+
|
|
82
|
+
- Fix Template Haskell highlighting (PR#63).
|
|
83
|
+
|
|
84
|
+
- Fix some S/R lexer errors (PR#91).
|
|
85
|
+
|
|
86
|
+
- Fix a bug in the Prolog lexer with names that start with 'is' (#810).
|
|
87
|
+
|
|
88
|
+
- Rewrite Dylan lexer, add Dylan LID lexer (PR#147).
|
|
39
89
|
|
|
40
|
-
-
|
|
90
|
+
- Add a Java quickstart document (PR#146).
|
|
41
91
|
|
|
42
|
-
-
|
|
92
|
+
- Add a "external/autopygmentize" file that can be used as .lessfilter (#802).
|
|
43
93
|
|
|
44
94
|
|
|
45
95
|
Version 1.5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
157c9feaccb8
|
|
@@ -64,7 +64,7 @@ def `guess_lexer(text, **options):`
|
|
|
64
64
|
def `guess_lexer_for_filename(filename, text, **options):`
|
|
65
65
|
As `guess_lexer()`, but only lexers which have a pattern in `filenames`
|
|
66
66
|
or `alias_filenames` that matches `filename` are taken into consideration.
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
`pygments.util.ClassNotFound` is raised if no lexer thinks it can handle the
|
|
69
69
|
content.
|
|
70
70
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
=====================
|
|
2
|
+
Use Pygments in Java
|
|
3
|
+
=====================
|
|
4
|
+
|
|
5
|
+
Thanks to `Jython <http://www.jython.org>`__ it is possible to use Pygments in
|
|
6
|
+
Java.
|
|
7
|
+
|
|
8
|
+
This page is a simple tutorial to get an idea of how this is working. You can
|
|
9
|
+
then look at the `Jython documentation <http://www.jython.org/docs/>`__ for more
|
|
10
|
+
advanced use.
|
|
11
|
+
|
|
12
|
+
Since version 1.5, Pygments is deployed on `Maven Central
|
|
13
|
+
<http://repo1.maven.org/maven2/org/pygments/pygments/>`__ as a JAR so is Jython
|
|
14
|
+
which makes it a lot easier to create the Java project.
|
|
15
|
+
|
|
16
|
+
Here is an example of a `Maven <http://www.maven.org>`__ ``pom.xml`` file for a
|
|
17
|
+
project running Pygments:
|
|
18
|
+
|
|
19
|
+
.. sourcecode:: xml
|
|
20
|
+
|
|
21
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
22
|
+
|
|
23
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
24
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
25
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
26
|
+
http://maven.apache.org/maven-v4_0_0.xsd">
|
|
27
|
+
<modelVersion>4.0.0</modelVersion>
|
|
28
|
+
<groupId>example</groupId>
|
|
29
|
+
<artifactId>example</artifactId>
|
|
30
|
+
<version>1.0-SNAPSHOT</version>
|
|
31
|
+
<dependencies>
|
|
32
|
+
<dependency>
|
|
33
|
+
<groupId>org.python</groupId>
|
|
34
|
+
<artifactId>jython-standalone</artifactId>
|
|
35
|
+
<version>2.5.3</version>
|
|
36
|
+
</dependency>
|
|
37
|
+
<dependency>
|
|
38
|
+
<groupId>org.pygments</groupId>
|
|
39
|
+
<artifactId>pygments</artifactId>
|
|
40
|
+
<version>1.5</version>
|
|
41
|
+
<scope>runtime</scope>
|
|
42
|
+
</dependency>
|
|
43
|
+
</dependencies>
|
|
44
|
+
</project>
|
|
45
|
+
|
|
46
|
+
The following Java example:
|
|
47
|
+
|
|
48
|
+
.. sourcecode:: java
|
|
49
|
+
|
|
50
|
+
PythonInterpreter interpreter = new PythonInterpreter();
|
|
51
|
+
|
|
52
|
+
// Set a variable with the content you want to work with
|
|
53
|
+
interpreter.set("code", code);
|
|
54
|
+
|
|
55
|
+
// Simple use Pygments as you would in Python
|
|
56
|
+
interpreter.exec("from pygments import highlight\n"
|
|
57
|
+
+ "from pygments.lexers import PythonLexer\n"
|
|
58
|
+
+ "from pygments.formatters import HtmlFormatter\n"
|
|
59
|
+
+ "\nresult = highlight(code, PythonLexer(), HtmlFormatter())");
|
|
60
|
+
|
|
61
|
+
// Get the result that has been set in a variable
|
|
62
|
+
System.out.println(interpreter.get("result", String.class));
|
|
63
|
+
|
|
64
|
+
will print something like:
|
|
65
|
+
|
|
66
|
+
.. sourcecode:: html
|
|
67
|
+
|
|
68
|
+
<div class="highlight">
|
|
69
|
+
<pre><span class="k">print</span> <span class="s">"Hello World"</span></pre>
|
|
70
|
+
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Best effort auto-pygmentization with transparent decompression
|
|
3
|
+
# (c) Reuben Thomas 2012-2013
|
|
4
|
+
# This program is in the public domain.
|
|
5
|
+
|
|
6
|
+
# Strategy: first see if pygmentize can find a lexer; if not, ask file; if that finds nothing, fail
|
|
7
|
+
# Set the environment variable PYGMENTIZE_OPTS to configure pygments.
|
|
8
|
+
|
|
9
|
+
# This program can be used as a .lessfilter for the less pager to auto-color less's output
|
|
10
|
+
|
|
11
|
+
lexer=`pygmentize -N "$1"`
|
|
12
|
+
if [ "$lexer" = "text" ]; then
|
|
13
|
+
file_common_opts="--brief --dereference --uncompress"
|
|
14
|
+
|
|
15
|
+
unset lexer
|
|
16
|
+
case `file --mime-type $file_common_opts "$1"` in
|
|
17
|
+
application/xml|image/svg+xml) lexer=xml;;
|
|
18
|
+
text/html) lexer=html;;
|
|
19
|
+
text/troff) lexer=nroff;;
|
|
20
|
+
text/x-asm) lexer=nasm;;
|
|
21
|
+
text/x-awk) lexer=awk;;
|
|
22
|
+
text/x-c) lexer=c;;
|
|
23
|
+
text/x-c++) lexer=cpp;;
|
|
24
|
+
text/x-diff) lexer=diff;;
|
|
25
|
+
text/x-fortran) lexer=fortran;;
|
|
26
|
+
text/x-gawk) lexer=gawk;;
|
|
27
|
+
text/x-java) lexer=java;;
|
|
28
|
+
text/x-lisp) lexer=common-lisp;;
|
|
29
|
+
text/x-lua) lexer=lua;;
|
|
30
|
+
text/x-makefile) lexer=make;;
|
|
31
|
+
text/x-msdos-batch) lexer=bat;;
|
|
32
|
+
text/x-nawk) lexer=nawk;;
|
|
33
|
+
text/x-pascal) lexer=pascal;;
|
|
34
|
+
text/x-perl) lexer=perl;;
|
|
35
|
+
text/x-php) lexer=php;;
|
|
36
|
+
text/x-po) lexer=po;;
|
|
37
|
+
text/x-python) lexer=python;;
|
|
38
|
+
text/x-ruby) lexer=ruby;;
|
|
39
|
+
text/x-shellscript) lexer=sh;;
|
|
40
|
+
text/x-tcl) lexer=tcl;;
|
|
41
|
+
text/x-tex|text/x-texinfo) lexer=latex;; # FIXME: texinfo really needs its own lexer
|
|
42
|
+
|
|
43
|
+
# Types that file outputs which pygmentize didn't support as of file 5.11, pygments 1.6rc1
|
|
44
|
+
# text/calendar
|
|
45
|
+
# text/PGP
|
|
46
|
+
# text/rtf
|
|
47
|
+
# text/texmacs
|
|
48
|
+
# text/x-bcpl
|
|
49
|
+
# text/x-info
|
|
50
|
+
# text/x-m4
|
|
51
|
+
# text/x-vcard
|
|
52
|
+
# text/x-xmcd
|
|
53
|
+
esac
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
encoding=`file --brief --mime-encoding $file_common_opts "$1"`
|
|
57
|
+
|
|
58
|
+
if [ -n "$lexer" ]; then
|
|
59
|
+
# FIXME: Specify input encoding rather than output encoding https://bitbucket.org/birkenfeld/pygments-main/issue/800
|
|
60
|
+
zcat "$1" | pygmentize -O encoding=$encoding,outencoding=UTF-8 $PYGMENTIZE_OPTS -l $lexer
|
|
61
|
+
exit 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
exit 1
|