pygments.rb 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +40 -0
- data/README.md +3 -0
- data/lexers +0 -0
- data/lib/pygments/popen.rb +3 -2
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/vendor/pygments-main/AUTHORS +20 -1
- data/vendor/pygments-main/CHANGES +55 -3
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/MANIFEST.in +1 -1
- data/vendor/pygments-main/Makefile +5 -8
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/doc/Makefile +153 -0
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
- data/vendor/pygments-main/doc/conf.py +249 -0
- data/vendor/pygments-main/doc/docs/api.rst +316 -0
- data/vendor/pygments-main/doc/docs/authors.rst +4 -0
- data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
- data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
- data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
- data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
- data/vendor/pygments-main/doc/docs/index.rst +66 -0
- data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
- data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
- data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
- data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
- data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
- data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
- data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
- data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
- data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
- data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
- data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
- data/vendor/pygments-main/doc/download.rst +41 -0
- data/vendor/pygments-main/doc/faq.rst +143 -0
- data/vendor/pygments-main/doc/index.rst +53 -0
- data/vendor/pygments-main/doc/languages.rst +151 -0
- data/vendor/pygments-main/doc/make.bat +190 -0
- data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
- data/vendor/pygments-main/external/autopygmentize +65 -48
- data/vendor/pygments-main/external/markdown-processor.py +15 -15
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +2 -3
- data/vendor/pygments-main/ez_setup.py +340 -234
- data/vendor/pygments-main/pygments/__init__.py +4 -4
- data/vendor/pygments-main/pygments/cmdline.py +81 -68
- 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 +11 -9
- data/vendor/pygments-main/pygments/formatter.py +3 -3
- data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
- data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +44 -26
- data/vendor/pygments-main/pygments/formatters/img.py +21 -14
- data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
- data/vendor/pygments-main/pygments/formatters/other.py +53 -6
- data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
- data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
- data/vendor/pygments-main/pygments/lexer.py +59 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
- data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
- data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
- data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
- data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
- data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
- data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
- data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
- data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
- data/vendor/pygments-main/pygments/lexers/math.py +438 -70
- data/vendor/pygments-main/pygments/lexers/other.py +885 -171
- data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
- data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
- data/vendor/pygments-main/pygments/lexers/special.py +7 -8
- data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
- data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
- data/vendor/pygments-main/pygments/lexers/text.py +208 -46
- data/vendor/pygments-main/pygments/lexers/web.py +729 -264
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/sphinxext.py +153 -0
- data/vendor/pygments-main/pygments/style.py +3 -2
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -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/igor.py +29 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- 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/paraiso_dark.py +125 -0
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
- 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/styles/xcode.py +51 -0
- data/vendor/pygments-main/pygments/token.py +4 -1
- data/vendor/pygments-main/pygments/unistring.py +6 -5
- data/vendor/pygments-main/pygments/util.py +35 -21
- data/vendor/pygments-main/scripts/check_sources.py +28 -44
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
- data/vendor/pygments-main/scripts/find_codetags.py +27 -19
- data/vendor/pygments-main/scripts/find_error.py +16 -13
- data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
- data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
- data/vendor/pygments-main/setup.py +19 -19
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
- data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
- data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
- data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
- data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
- data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
- data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
- data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
- data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
- data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
- data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
- data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
- data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
- data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
- data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
- data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
- data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
- data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
- data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
- data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
- data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
- data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
- data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
- data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
- data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
- data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
- data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
- data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
- data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
- data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
- data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
- data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
- data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
- data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
- data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
- data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
- data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
- data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
- data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
- data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
- data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
- data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
- data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
- data/vendor/pygments-main/tests/run.py +14 -19
- data/vendor/pygments-main/tests/string_asserts.py +22 -0
- data/vendor/pygments-main/tests/test_basic_api.py +28 -14
- data/vendor/pygments-main/tests/test_cfm.py +46 -0
- data/vendor/pygments-main/tests/test_clexer.py +208 -3
- data/vendor/pygments-main/tests/test_cmdline.py +6 -5
- data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
- data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
- data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
- data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
- data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
- data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
- data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
- data/vendor/pygments-main/tests/test_token.py +3 -3
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +1 -1
- metadata +138 -51
- data/vendor/pygments-main/docs/generate.py +0 -472
- data/vendor/pygments-main/docs/src/api.txt +0 -270
- data/vendor/pygments-main/docs/src/authors.txt +0 -5
- data/vendor/pygments-main/docs/src/changelog.txt +0 -5
- data/vendor/pygments-main/docs/src/index.txt +0 -69
- data/vendor/pygments-main/docs/src/installation.txt +0 -71
- data/vendor/pygments-main/external/rst-directive-old.py +0 -77
- data/vendor/pygments-main/scripts/reindent.py +0 -291
- data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
- data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -0,0 +1 @@
|
|
1
|
+
.. include:: ../../CHANGES
|
@@ -4,8 +4,8 @@
|
|
4
4
|
Command Line Interface
|
5
5
|
======================
|
6
6
|
|
7
|
-
You can use Pygments from the shell, provided you installed the
|
8
|
-
script::
|
7
|
+
You can use Pygments from the shell, provided you installed the
|
8
|
+
:program:`pygmentize` script::
|
9
9
|
|
10
10
|
$ pygmentize test.py
|
11
11
|
print "Hello World"
|
@@ -28,7 +28,7 @@ written to stdout.
|
|
28
28
|
The ``-f`` option selects a formatter (as with ``-l``, it can also be omitted
|
29
29
|
if an output file name is given and has a supported extension).
|
30
30
|
If no output file name is given and ``-f`` is omitted, the
|
31
|
-
|
31
|
+
:class:`.TerminalFormatter` is used.
|
32
32
|
|
33
33
|
The above command could therefore also be given as::
|
34
34
|
|
@@ -82,14 +82,15 @@ Usage is as follows::
|
|
82
82
|
generates a CSS style sheet (because you selected the HTML formatter) for
|
83
83
|
the "colorful" style prepending a ".syntax" selector to all style rules.
|
84
84
|
|
85
|
-
For an explanation what ``-a`` means for
|
86
|
-
the `arg` argument for the formatter's
|
85
|
+
For an explanation what ``-a`` means for :doc:`a particular formatter
|
86
|
+
<formatters>`, look for the `arg` argument for the formatter's
|
87
|
+
:meth:`.get_style_defs()` method.
|
87
88
|
|
88
89
|
|
89
90
|
Getting lexer names
|
90
91
|
-------------------
|
91
92
|
|
92
|
-
|
93
|
+
.. versionadded:: 1.0
|
93
94
|
|
94
95
|
The ``-N`` option guesses a lexer name for a given filename, so that ::
|
95
96
|
|
@@ -125,7 +126,7 @@ will print the help for the Python lexer, etc.
|
|
125
126
|
A note on encodings
|
126
127
|
-------------------
|
127
128
|
|
128
|
-
|
129
|
+
.. versionadded:: 0.9
|
129
130
|
|
130
131
|
Pygments tries to be smart regarding encodings in the formatting process:
|
131
132
|
|
@@ -141,7 +142,4 @@ Pygments tries to be smart regarding encodings in the formatting process:
|
|
141
142
|
|
142
143
|
* If you don't give an encoding and haven't given an output file (that means
|
143
144
|
output is written to the console), the default encoding for lexer and
|
144
|
-
formatter is the terminal encoding (
|
145
|
-
|
146
|
-
|
147
|
-
.. _a particular formatter: formatters.txt
|
145
|
+
formatter is the terminal encoding (``sys.stdout.encoding``).
|
@@ -4,7 +4,7 @@
|
|
4
4
|
Filters
|
5
5
|
=======
|
6
6
|
|
7
|
-
|
7
|
+
.. versionadded:: 0.7
|
8
8
|
|
9
9
|
You can filter token streams coming from lexers to improve or annotate the
|
10
10
|
output. For example, you can highlight special words in comments, convert
|
@@ -31,12 +31,11 @@ To get a list of all registered filters by name, you can use the
|
|
31
31
|
`get_all_filters()` function from the `pygments.filters` module that returns an
|
32
32
|
iterable for all known filters.
|
33
33
|
|
34
|
-
If you want to write your own filter, have a look at
|
35
|
-
|
36
|
-
.. _Write your own filter: filterdevelopment.txt
|
34
|
+
If you want to write your own filter, have a look at :doc:`Write your own filter
|
35
|
+
<filterdevelopment>`.
|
37
36
|
|
38
37
|
|
39
38
|
Builtin Filters
|
40
39
|
===============
|
41
40
|
|
42
|
-
|
41
|
+
.. pygmentsdoc:: filters
|
data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst}
RENAMED
@@ -4,7 +4,7 @@
|
|
4
4
|
Write your own formatter
|
5
5
|
========================
|
6
6
|
|
7
|
-
As well as creating
|
7
|
+
As well as creating :doc:`your own lexer <lexerdevelopment>`, writing a new
|
8
8
|
formatter for Pygments is easy and straightforward.
|
9
9
|
|
10
10
|
A formatter is a class that is initialized with some keyword arguments (the
|
@@ -12,8 +12,6 @@ Common options
|
|
12
12
|
All formatters support these options:
|
13
13
|
|
14
14
|
`encoding`
|
15
|
-
*New in Pygments 0.6.*
|
16
|
-
|
17
15
|
If given, must be an encoding name (such as ``"utf-8"``). This will
|
18
16
|
be used to convert the token strings (which are Unicode strings)
|
19
17
|
to byte strings in the output (default: ``None``).
|
@@ -30,19 +28,21 @@ All formatters support these options:
|
|
30
28
|
supports Unicode arguments to `write()`. Using a regular file object
|
31
29
|
wouldn't work.
|
32
30
|
|
33
|
-
|
34
|
-
*New in Pygments 0.7.*
|
31
|
+
.. versionadded:: 0.6
|
35
32
|
|
33
|
+
`outencoding`
|
36
34
|
When using Pygments from the command line, any `encoding` option given is
|
37
35
|
passed to the lexer and the formatter. This is sometimes not desirable,
|
38
36
|
for example if you want to set the input encoding to ``"guess"``.
|
39
37
|
Therefore, `outencoding` has been introduced which overrides `encoding`
|
40
38
|
for the formatter if given.
|
41
39
|
|
40
|
+
.. versionadded:: 0.7
|
41
|
+
|
42
42
|
|
43
43
|
Formatter classes
|
44
44
|
=================
|
45
45
|
|
46
|
-
All these classes are importable from
|
46
|
+
All these classes are importable from :mod:`pygments.formatters`.
|
47
47
|
|
48
|
-
|
48
|
+
.. pygmentsdoc:: formatters
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Pygments documentation
|
2
|
+
======================
|
3
|
+
|
4
|
+
**Starting with Pygments**
|
5
|
+
|
6
|
+
.. toctree::
|
7
|
+
:maxdepth: 1
|
8
|
+
|
9
|
+
../download
|
10
|
+
quickstart
|
11
|
+
cmdline
|
12
|
+
|
13
|
+
**Builtin components**
|
14
|
+
|
15
|
+
.. toctree::
|
16
|
+
:maxdepth: 1
|
17
|
+
|
18
|
+
lexers
|
19
|
+
filters
|
20
|
+
formatters
|
21
|
+
styles
|
22
|
+
|
23
|
+
**Reference**
|
24
|
+
|
25
|
+
.. toctree::
|
26
|
+
:maxdepth: 1
|
27
|
+
|
28
|
+
unicode
|
29
|
+
tokens
|
30
|
+
api
|
31
|
+
|
32
|
+
**Hacking for Pygments**
|
33
|
+
|
34
|
+
.. toctree::
|
35
|
+
:maxdepth: 1
|
36
|
+
|
37
|
+
lexerdevelopment
|
38
|
+
formatterdevelopment
|
39
|
+
filterdevelopment
|
40
|
+
plugins
|
41
|
+
|
42
|
+
**Hints and tricks**
|
43
|
+
|
44
|
+
.. toctree::
|
45
|
+
:maxdepth: 1
|
46
|
+
|
47
|
+
rstdirective
|
48
|
+
moinmoin
|
49
|
+
java
|
50
|
+
integrate
|
51
|
+
|
52
|
+
**About Pygments**
|
53
|
+
|
54
|
+
.. toctree::
|
55
|
+
:maxdepth: 1
|
56
|
+
|
57
|
+
changelog
|
58
|
+
authors
|
59
|
+
|
60
|
+
|
61
|
+
If you find bugs or have suggestions for the documentation, please look
|
62
|
+
:ref:`here <contribute>` for info on how to contact the team.
|
63
|
+
|
64
|
+
.. XXX You can download an offline version of this documentation from the
|
65
|
+
:doc:`download page </download>`.
|
66
|
+
|
@@ -23,8 +23,9 @@ Markdown
|
|
23
23
|
--------
|
24
24
|
|
25
25
|
Since Pygments 0.9, the distribution ships Markdown_ preprocessor sample code
|
26
|
-
that uses Pygments to render source code in
|
27
|
-
You can copy and adapt it to your
|
26
|
+
that uses Pygments to render source code in
|
27
|
+
:file:`external/markdown-processor.py`. You can copy and adapt it to your
|
28
|
+
liking.
|
28
29
|
|
29
30
|
.. _Markdown: http://www.freewisdom.org/projects/python-markdown/
|
30
31
|
|
@@ -41,8 +42,3 @@ Bash completion
|
|
41
42
|
|
42
43
|
The source distribution contains a file ``external/pygments.bashcomp`` that
|
43
44
|
sets up completion for the ``pygmentize`` command in bash.
|
44
|
-
|
45
|
-
Java
|
46
|
-
----
|
47
|
-
|
48
|
-
See the `Java quickstart <java.txt>`_ document.
|
File without changes
|
@@ -7,13 +7,13 @@ Write your own lexer
|
|
7
7
|
If a lexer for your favorite language is missing in the Pygments package, you can
|
8
8
|
easily write your own and extend Pygments.
|
9
9
|
|
10
|
-
All you need can be found inside the
|
11
|
-
the
|
12
|
-
some keyword arguments (the lexer options) and that provides a
|
13
|
-
|
14
|
-
the data to parse.
|
10
|
+
All you need can be found inside the :mod:`pygments.lexer` module. As you can
|
11
|
+
read in the :doc:`API documentation <api>`, a lexer is a class that is
|
12
|
+
initialized with some keyword arguments (the lexer options) and that provides a
|
13
|
+
:meth:`.get_tokens_unprocessed()` method which is given a string or unicode
|
14
|
+
object with the data to parse.
|
15
15
|
|
16
|
-
The
|
16
|
+
The :meth:`.get_tokens_unprocessed()` method must return an iterator or iterable
|
17
17
|
containing tuples in the form ``(index, token, value)``. Normally you don't need
|
18
18
|
to do this since there are numerous base lexers you can subclass.
|
19
19
|
|
@@ -21,9 +21,9 @@ to do this since there are numerous base lexers you can subclass.
|
|
21
21
|
RegexLexer
|
22
22
|
==========
|
23
23
|
|
24
|
-
A very powerful (but quite easy to use) lexer is the
|
25
|
-
base class allows you to define lexing rules in terms of *regular
|
26
|
-
for different *states*.
|
24
|
+
A very powerful (but quite easy to use) lexer is the :class:`RegexLexer`. This
|
25
|
+
lexer base class allows you to define lexing rules in terms of *regular
|
26
|
+
expressions* for different *states*.
|
27
27
|
|
28
28
|
States are groups of regular expressions that are matched against the input
|
29
29
|
string at the *current position*. If one of these expressions matches, a
|
@@ -289,8 +289,9 @@ There are a few more things you can do with states:
|
|
289
289
|
the closing ``*/``. Then, both states are popped from the stack again and
|
290
290
|
lexing continues in the root state.
|
291
291
|
|
292
|
-
|
293
|
-
|
292
|
+
.. versionadded:: 0.9
|
293
|
+
The tuple can contain the special ``'#push'`` and ``'#pop'`` (but not
|
294
|
+
``'#pop:n'``) directives.
|
294
295
|
|
295
296
|
|
296
297
|
- You can include the rules of a state in the definition of another. This is
|
@@ -598,6 +599,4 @@ the ``get_tokens_unprocessed()`` method. The following lexer subclasses the
|
|
598
599
|
|
599
600
|
The `PhpLexer` and `LuaLexer` use this method to resolve builtin functions.
|
600
601
|
|
601
|
-
|
602
|
-
|
603
|
-
.. _filter: filters.txt
|
602
|
+
.. note:: Do not confuse this with the :doc:`filter <filters>` system.
|
@@ -18,14 +18,13 @@ Currently, **all lexers** support these options:
|
|
18
18
|
`ensurenl`
|
19
19
|
Make sure that the input ends with a newline (default: ``True``). This
|
20
20
|
is required for some lexers that consume input linewise.
|
21
|
-
|
21
|
+
|
22
|
+
.. versionadded:: 1.3
|
22
23
|
|
23
24
|
`tabsize`
|
24
25
|
If given and greater than 0, expand tabs in the input (default: ``0``).
|
25
26
|
|
26
27
|
`encoding`
|
27
|
-
*New in Pygments 0.6.*
|
28
|
-
|
29
28
|
If given, must be an encoding name (such as ``"utf-8"``). This encoding
|
30
29
|
will be used to convert the input string to Unicode (if it is not already
|
31
30
|
a Unicode string). The default is ``"latin1"``.
|
@@ -35,18 +34,21 @@ Currently, **all lexers** support these options:
|
|
35
34
|
`chardet library <http://chardet.feedparser.org/>`__ is used to
|
36
35
|
guess the encoding of the input.
|
37
36
|
|
37
|
+
.. versionadded:: 0.6
|
38
|
+
|
38
39
|
|
39
40
|
The "Short Names" field lists the identifiers that can be used with the
|
40
41
|
`get_lexer_by_name()` function.
|
41
42
|
|
42
43
|
These lexers are builtin and can be imported from `pygments.lexers`:
|
43
44
|
|
44
|
-
|
45
|
+
.. pygmentsdoc:: lexers
|
46
|
+
|
45
47
|
|
46
48
|
Iterating over all lexers
|
47
49
|
-------------------------
|
48
50
|
|
49
|
-
|
51
|
+
.. versionadded:: 0.6
|
50
52
|
|
51
53
|
To get all lexers (both the builtin and the plugin ones), you can
|
52
54
|
use the `get_all_lexers()` function from the `pygments.lexers`
|
File without changes
|
File without changes
|
@@ -58,8 +58,8 @@ can be produced by:
|
|
58
58
|
|
59
59
|
print HtmlFormatter().get_style_defs('.highlight')
|
60
60
|
|
61
|
-
The argument to
|
62
|
-
may look like this:
|
61
|
+
The argument to :func:`get_style_defs` is used as an additional CSS selector:
|
62
|
+
the output may look like this:
|
63
63
|
|
64
64
|
.. sourcecode:: css
|
65
65
|
|
@@ -71,9 +71,9 @@ may look like this:
|
|
71
71
|
Options
|
72
72
|
=======
|
73
73
|
|
74
|
-
The
|
75
|
-
a file object if given. The formatted output will then be written to
|
76
|
-
instead of being returned as a string.
|
74
|
+
The :func:`highlight()` function supports a fourth argument called *outfile*, it
|
75
|
+
must be a file object if given. The formatted output will then be written to
|
76
|
+
this file instead of being returned as a string.
|
77
77
|
|
78
78
|
Lexers and formatters both support options. They are given to them as keyword
|
79
79
|
arguments either to the class or to the lookup method:
|
@@ -103,9 +103,9 @@ Important options include:
|
|
103
103
|
|
104
104
|
|
105
105
|
For an overview of builtin lexers and formatters and their options, visit the
|
106
|
-
|
106
|
+
:doc:`lexer <lexers>` and :doc:`formatters <formatters>` lists.
|
107
107
|
|
108
|
-
For a documentation on filters, see
|
108
|
+
For a documentation on filters, see :doc:`this page <filters>`.
|
109
109
|
|
110
110
|
|
111
111
|
Lexer and formatter lookup
|
@@ -131,9 +131,9 @@ one of the following methods:
|
|
131
131
|
All these functions accept keyword arguments; they will be passed to the lexer
|
132
132
|
as options.
|
133
133
|
|
134
|
-
A similar API is available for formatters: use
|
135
|
-
|
136
|
-
for this purpose.
|
134
|
+
A similar API is available for formatters: use :func:`.get_formatter_by_name()`
|
135
|
+
and :func:`.get_formatter_for_filename()` from the :mod:`pygments.formatters`
|
136
|
+
module for this purpose.
|
137
137
|
|
138
138
|
|
139
139
|
Guessing lexers
|
@@ -153,16 +153,17 @@ or some template tags), use these functions:
|
|
153
153
|
>>> guess_lexer_for_filename('test.py', 'print "Hello World!"')
|
154
154
|
<pygments.lexers.PythonLexer>
|
155
155
|
|
156
|
-
|
157
|
-
method and returns the one for which it returns the
|
156
|
+
:func:`.guess_lexer()` passes the given content to the lexer classes'
|
157
|
+
:meth:`analyse_text()` method and returns the one for which it returns the
|
158
|
+
highest number.
|
158
159
|
|
159
160
|
All lexers have two different filename pattern lists: the primary and the
|
160
|
-
secondary one. The
|
161
|
-
list, whose entries are supposed to be unique among all lexers.
|
162
|
-
|
163
|
-
look at the primary and secondary filename patterns if the filename matches.
|
161
|
+
secondary one. The :func:`.get_lexer_for_filename()` function only uses the
|
162
|
+
primary list, whose entries are supposed to be unique among all lexers.
|
163
|
+
:func:`.guess_lexer_for_filename()`, however, will first loop through all lexers
|
164
|
+
and look at the primary and secondary filename patterns if the filename matches.
|
164
165
|
If only one lexer matches, it is returned, else the guessing mechanism of
|
165
|
-
|
166
|
+
:func:`.guess_lexer()` is used with the matching lexers.
|
166
167
|
|
167
168
|
As usual, keyword arguments to these functions are given to the created lexer
|
168
169
|
as options.
|
@@ -171,7 +172,8 @@ as options.
|
|
171
172
|
Command line usage
|
172
173
|
==================
|
173
174
|
|
174
|
-
You can use Pygments from the command line, using the
|
175
|
+
You can use Pygments from the command line, using the :program:`pygmentize`
|
176
|
+
script::
|
175
177
|
|
176
178
|
$ pygmentize test.py
|
177
179
|
|
@@ -199,4 +201,5 @@ it can be created with::
|
|
199
201
|
|
200
202
|
where ``default`` is the style name.
|
201
203
|
|
202
|
-
More options and tricks and be found in the
|
204
|
+
More options and tricks and be found in the :doc:`command line reference
|
205
|
+
<cmdline>`.
|
File without changes
|
@@ -68,7 +68,7 @@ they can be used for a variety of formatters.)
|
|
68
68
|
|
69
69
|
To make the style usable for Pygments, you must
|
70
70
|
|
71
|
-
* either register it as a plugin (see
|
71
|
+
* either register it as a plugin (see :doc:`the plugin docs <plugins>`)
|
72
72
|
* or drop it into the `styles` subpackage of your Pygments distribution one style
|
73
73
|
class per style, where the file name is the style name and the class name is
|
74
74
|
`StylenameClass`. For example, if your style should be called
|
@@ -132,7 +132,7 @@ To get a list of known styles you can use this snippet:
|
|
132
132
|
Getting a list of available styles
|
133
133
|
==================================
|
134
134
|
|
135
|
-
|
135
|
+
.. versionadded:: 0.6
|
136
136
|
|
137
137
|
Because it could be that a plugin registered a style, there is
|
138
138
|
a way to iterate over all styles:
|
@@ -4,7 +4,9 @@
|
|
4
4
|
Builtin Tokens
|
5
5
|
==============
|
6
6
|
|
7
|
-
|
7
|
+
.. module:: pygments.token
|
8
|
+
|
9
|
+
In the :mod:`pygments.token` module, there is a special object called `Token`
|
8
10
|
that is used to create token types.
|
9
11
|
|
10
12
|
You can create a new token type by accessing an attribute of `Token`:
|
@@ -30,8 +32,8 @@ As of Pygments 0.7 you can also use the ``in`` operator to perform set tests:
|
|
30
32
|
>>> Comment in Comment.Multi
|
31
33
|
False
|
32
34
|
|
33
|
-
This can be useful in
|
34
|
-
using the base lexers.
|
35
|
+
This can be useful in :doc:`filters <filters>` and if you write lexers on your
|
36
|
+
own without using the base lexers.
|
35
37
|
|
36
38
|
You can also split a token type into a hierarchy, and get the parent of it:
|
37
39
|
|
@@ -55,7 +57,7 @@ For some tokens aliases are already defined:
|
|
55
57
|
>>> String
|
56
58
|
Token.Literal.String
|
57
59
|
|
58
|
-
Inside the
|
60
|
+
Inside the :mod:`pygments.token` module the following aliases are defined:
|
59
61
|
|
60
62
|
============= ============================ ====================================
|
61
63
|
`Text` `Token.Text` for any type of text data
|
@@ -251,6 +253,9 @@ Literals
|
|
251
253
|
`Number`
|
252
254
|
Token type for any number literal.
|
253
255
|
|
256
|
+
`Number.Bin`
|
257
|
+
Token type for binary literals (e.g. ``0b101010``).
|
258
|
+
|
254
259
|
`Number.Float`
|
255
260
|
Token type for float literals (e.g. ``42.0``).
|
256
261
|
|
@@ -280,7 +285,7 @@ Operators
|
|
280
285
|
Punctuation
|
281
286
|
===========
|
282
287
|
|
283
|
-
|
288
|
+
.. versionadded:: 0.7
|
284
289
|
|
285
290
|
`Punctuation`
|
286
291
|
For any punctuation which is not an operator (e.g. ``[``, ``(``...)
|
@@ -345,5 +350,3 @@ highlight a programming language but a patch file.
|
|
345
350
|
|
346
351
|
`Generic.Traceback`
|
347
352
|
Marks the token value as a part of an error traceback.
|
348
|
-
|
349
|
-
.. _filters: filters.txt
|