pygments.rb 0.3.7 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/CHANGELOG +9 -0
  2. data/CHANGELOG.md +6 -0
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/lexers +0 -0
  6. data/lib/pygments/version.rb +1 -1
  7. data/test/test_pygments.rb +0 -1
  8. data/vendor/pygments-main/AUTHORS +14 -1
  9. data/vendor/pygments-main/CHANGES +56 -6
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/Makefile +1 -1
  12. data/vendor/pygments-main/REVISION +1 -0
  13. data/vendor/pygments-main/docs/generate.py +1 -1
  14. data/vendor/pygments-main/docs/src/api.txt +1 -1
  15. data/vendor/pygments-main/docs/src/index.txt +1 -1
  16. data/vendor/pygments-main/docs/src/integrate.txt +5 -0
  17. data/vendor/pygments-main/docs/src/java.txt +70 -0
  18. data/vendor/pygments-main/external/autopygmentize +64 -0
  19. data/vendor/pygments-main/external/markdown-processor.py +2 -2
  20. data/vendor/pygments-main/external/moin-parser.py +1 -1
  21. data/vendor/pygments-main/external/rst-directive-old.py +1 -1
  22. data/vendor/pygments-main/external/rst-directive.py +1 -1
  23. data/vendor/pygments-main/pygments/__init__.py +2 -2
  24. data/vendor/pygments-main/pygments/cmdline.py +14 -6
  25. data/vendor/pygments-main/pygments/console.py +1 -1
  26. data/vendor/pygments-main/pygments/filter.py +1 -1
  27. data/vendor/pygments-main/pygments/filters/__init__.py +1 -1
  28. data/vendor/pygments-main/pygments/formatter.py +1 -1
  29. data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
  30. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -1
  31. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  32. data/vendor/pygments-main/pygments/formatters/html.py +73 -2
  33. data/vendor/pygments-main/pygments/formatters/img.py +1 -1
  34. data/vendor/pygments-main/pygments/formatters/latex.py +1 -1
  35. data/vendor/pygments-main/pygments/formatters/other.py +1 -1
  36. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  37. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  38. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  39. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  40. data/vendor/pygments-main/pygments/lexer.py +76 -12
  41. data/vendor/pygments-main/pygments/lexers/__init__.py +2 -2
  42. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  43. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
  44. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +4 -1
  45. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
  46. data/vendor/pygments-main/pygments/lexers/_mapping.py +26 -10
  47. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +11 -0
  48. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
  49. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -2
  50. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +14 -3
  51. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
  52. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +2 -2
  53. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +6 -6
  54. data/vendor/pygments-main/pygments/lexers/agile.py +6 -4
  55. data/vendor/pygments-main/pygments/lexers/asm.py +40 -2
  56. data/vendor/pygments-main/pygments/lexers/compiled.py +751 -438
  57. data/vendor/pygments-main/pygments/lexers/dalvik.py +2 -2
  58. data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
  59. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  60. data/vendor/pygments-main/pygments/lexers/functional.py +6 -5
  61. data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
  62. data/vendor/pygments-main/pygments/lexers/jvm.py +130 -16
  63. data/vendor/pygments-main/pygments/lexers/math.py +250 -9
  64. data/vendor/pygments-main/pygments/lexers/other.py +518 -13
  65. data/vendor/pygments-main/pygments/lexers/parsers.py +3 -2
  66. data/vendor/pygments-main/pygments/lexers/shell.py +48 -2
  67. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  68. data/vendor/pygments-main/pygments/lexers/sql.py +1 -1
  69. data/vendor/pygments-main/pygments/lexers/templates.py +7 -6
  70. data/vendor/pygments-main/pygments/lexers/text.py +9 -9
  71. data/vendor/pygments-main/pygments/lexers/web.py +264 -51
  72. data/vendor/pygments-main/pygments/plugin.py +1 -1
  73. data/vendor/pygments-main/pygments/scanner.py +1 -1
  74. data/vendor/pygments-main/pygments/style.py +1 -1
  75. data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
  76. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  77. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  78. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  79. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  80. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  81. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  82. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  83. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  84. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  85. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  86. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  87. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  88. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  89. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  90. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  91. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  92. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  93. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  94. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  95. data/vendor/pygments-main/pygments/token.py +1 -1
  96. data/vendor/pygments-main/pygments/unistring.py +1 -1
  97. data/vendor/pygments-main/pygments/util.py +1 -1
  98. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  99. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
  100. data/vendor/pygments-main/scripts/find_codetags.py +1 -1
  101. data/vendor/pygments-main/scripts/find_error.py +5 -6
  102. data/vendor/pygments-main/setup.cfg +1 -0
  103. data/vendor/pygments-main/setup.py +6 -4
  104. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  105. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  106. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  107. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  108. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  109. data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
  110. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  111. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  112. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  113. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  114. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +2 -2
  115. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  116. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  117. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  118. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  119. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  120. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +191 -701
  121. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  122. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  123. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  124. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  125. data/vendor/pygments-main/tests/old_run.py +1 -1
  126. data/vendor/pygments-main/tests/run.py +3 -2
  127. data/vendor/pygments-main/tests/support/tags +36 -0
  128. data/vendor/pygments-main/tests/test_basic_api.py +3 -2
  129. data/vendor/pygments-main/tests/test_clexer.py +1 -1
  130. data/vendor/pygments-main/tests/test_cmdline.py +1 -1
  131. data/vendor/pygments-main/tests/test_examplefiles.py +1 -1
  132. data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
  133. data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
  134. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  135. data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
  136. data/vendor/pygments-main/tests/test_token.py +1 -1
  137. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  138. data/vendor/pygments-main/tests/test_util.py +5 -4
  139. metadata +26 -2
data/CHANGELOG ADDED
@@ -0,0 +1,9 @@
1
+ changelog
2
+ ===========
3
+
4
+ Version 0.3.4 (Dec 28, 2012)
5
+
6
+ * Add support for Windows
7
+ * Add MIT license
8
+
9
+
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  changelog
2
2
  ===========
3
3
 
4
+ Version 0.3.7 (Jan 2, 2013)
5
+ -----------------------------
6
+
7
+ * Fixed missing custom lexers
8
+ * Added syntax highlighting for Hxml
9
+
4
10
  Version 0.3.4 (Dec 28, 2012)
5
11
  -----------------------------
6
12
 
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
@@ -1,3 +1,3 @@
1
1
  module Pygments
2
- VERSION = '0.3.7'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -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
- (in development, to be released xx November 2012)
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
- - Fix Template Haskell highlighting (PR#63)
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
- - Fix some S/R lexer errors (PR#91)
90
+ - Add a Java quickstart document (PR#146).
41
91
 
42
- - Fix a bug in the Prolog lexer with names that start with 'is' (#810)
92
+ - Add a "external/autopygmentize" file that can be used as .lessfilter (#802).
43
93
 
44
94
 
45
95
  Version 1.5
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2012 by the respective authors (see AUTHORS file).
1
+ Copyright (c) 2006-2013 by the respective authors (see AUTHORS file).
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Combines scripts for common tasks.
6
6
  #
7
- # :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
7
+ # :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
8
  # :license: BSD, see LICENSE for details.
9
9
  #
10
10
 
@@ -0,0 +1 @@
1
+ 157c9feaccb8
@@ -6,7 +6,7 @@
6
6
 
7
7
  Generates a bunch of html files containing the documentation.
8
8
 
9
- :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
9
+ :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
10
10
  :license: BSD, see LICENSE for details.
11
11
  """
12
12
 
@@ -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
 
@@ -37,7 +37,7 @@ Welcome to the Pygments documentation.
37
37
  - `Write your own lexer <lexerdevelopment.txt>`_
38
38
 
39
39
  - `Write your own formatter <formatterdevelopment.txt>`_
40
-
40
+
41
41
  - `Write your own filter <filterdevelopment.txt>`_
42
42
 
43
43
  - `Register plugins <plugins.txt>`_
@@ -41,3 +41,8 @@ Bash completion
41
41
 
42
42
  The source distribution contains a file ``external/pygments.bashcomp`` that
43
43
  sets up completion for the ``pygmentize`` command in bash.
44
+
45
+ Java
46
+ ----
47
+
48
+ See the `Java quickstart <java.txt>`_ document.
@@ -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">&quot;Hello World&quot;</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