
After go1.16, go will use module mode by default, even when the repository is checked out under GOPATH or in a one-off directory. Add go.mod, go.sum to keep this repo buildable without opting out of the module mode. > go mod init github.com/mmcgrana/gobyexample > go mod tidy > go mod vendor In module mode, the 'vendor' directory is special and its contents will be actively maintained by the go command. pygments aren't the dependency the go will know about, so it will delete the contents from vendor directory. Move it to `third_party` directory now. And, vendor the blackfriday package. Note: the tutorial contents are not affected by the change in go1.16 because all the examples in this tutorial ask users to run the go command with the explicit list of files to be compiled (e.g. `go run hello-world.go` or `go build command-line-arguments.go`). When the source list is provided, the go command does not have to compute the build list and whether it's running in GOPATH mode or module mode becomes irrelevant.
70 lines
2.0 KiB
ReStructuredText
70 lines
2.0 KiB
ReStructuredText
.. -*- mode: rst -*-
|
|
|
|
================
|
|
Available lexers
|
|
================
|
|
|
|
This page lists all available builtin lexers and the options they take.
|
|
|
|
Currently, **all lexers** support these options:
|
|
|
|
`stripnl`
|
|
Strip leading and trailing newlines from the input (default: ``True``)
|
|
|
|
`stripall`
|
|
Strip all leading and trailing whitespace from the input (default:
|
|
``False``).
|
|
|
|
`ensurenl`
|
|
Make sure that the input ends with a newline (default: ``True``). This
|
|
is required for some lexers that consume input linewise.
|
|
|
|
.. versionadded:: 1.3
|
|
|
|
`tabsize`
|
|
If given and greater than 0, expand tabs in the input (default: ``0``).
|
|
|
|
`encoding`
|
|
If given, must be an encoding name (such as ``"utf-8"``). This encoding
|
|
will be used to convert the input string to Unicode (if it is not already
|
|
a Unicode string). The default is ``"guess"``.
|
|
|
|
If this option is set to ``"guess"``, a simple UTF-8 vs. Latin-1
|
|
detection is used, if it is set to ``"chardet"``, the
|
|
`chardet library <http://chardet.feedparser.org/>`_ is used to
|
|
guess the encoding of the input.
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
|
|
The "Short Names" field lists the identifiers that can be used with the
|
|
`get_lexer_by_name()` function.
|
|
|
|
These lexers are builtin and can be imported from `pygments.lexers`:
|
|
|
|
.. pygmentsdoc:: lexers
|
|
|
|
|
|
Iterating over all lexers
|
|
-------------------------
|
|
|
|
.. versionadded:: 0.6
|
|
|
|
To get all lexers (both the builtin and the plugin ones), you can
|
|
use the `get_all_lexers()` function from the `pygments.lexers`
|
|
module:
|
|
|
|
.. sourcecode:: pycon
|
|
|
|
>>> from pygments.lexers import get_all_lexers
|
|
>>> i = get_all_lexers()
|
|
>>> i.next()
|
|
('Diff', ('diff',), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch'))
|
|
>>> i.next()
|
|
('Delphi', ('delphi', 'objectpascal', 'pas', 'pascal'), ('*.pas',), ('text/x-pascal',))
|
|
>>> i.next()
|
|
('XML+Ruby', ('xml+erb', 'xml+ruby'), (), ())
|
|
|
|
As you can see, the return value is an iterator which yields tuples
|
|
in the form ``(name, aliases, filetypes, mimetypes)``.
|