diff options
author | amitkummer <49096391+amitkummer@users.noreply.github.com> | 2021-10-02 13:26:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-02 12:26:24 +0200 |
commit | b10a543183598f80ad5928a45c412ecda68e9b8e (patch) | |
tree | b237a2e7f5f27358cec5e1765414b791452afcfd /doc/docs | |
parent | 320853d7e46f96bd60acbfb23fc74b58104098c1 (diff) | |
download | pygments-git-b10a543183598f80ad5928a45c412ecda68e9b8e.tar.gz |
Add documentation for missing CLI options (#1900)
Add documentation for the -N, -g, -s and --json command line options.
Diffstat (limited to 'doc/docs')
-rw-r--r-- | doc/docs/cmdline.rst | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/docs/cmdline.rst b/doc/docs/cmdline.rst index afb02872..bbfd9125 100644 --- a/doc/docs/cmdline.rst +++ b/doc/docs/cmdline.rst @@ -99,6 +99,37 @@ The ``-N`` option guesses a lexer name for a given filename, so that :: will print out ``python``. It won't highlight anything yet. If no specific lexer is known for that filename, ``text`` is printed. +Additionally, there is the ``-C`` option, which is just like like ``-N``, except +that it prints out a lexer name based solely on a given content from standard +input. + + +Guessing the lexer from the file contents +----------------------------------------- + +The ``-g`` option will try to guess the correct lexer from the file contents, +or pass through as plain text if nothing can be guessed. This option also looks +for Vim modelines in the text, and for *some* languages, shebangs. Usage is as +follows:: + + $ pygmentize -g setup.py + +Note though, that this option is not very relaiable, and probably should be +used only if Pygments is not able to guess the correct lexer from the file's +extension. + + +Highlighting stdin until EOF +---------------------------- + +The ``-s`` option processes lines one at a time until EOF, rather than waiting +to process the entire file. This only works for stdin, only for lexers with no +line-spanning constructs, and is intended for streaming input such as you get +from `tail -f`. Usage is as follows:: + + $ tail -f sql.log | pygmentize -s -l sql + + Custom Lexers and Formatters ---------------------------- @@ -117,6 +148,7 @@ You can also specify the name of your class with a colon:: For more information, see :doc:`the Pygments documentation on Lexer development <lexerdevelopment>`. + Getting help ------------ @@ -128,6 +160,14 @@ only one category, give it as an argument:: will list only all installed filters. +.. versionadded:: 2.11 + +The ``--json`` option can be used in conjunction with the ``-L`` option to +output it's contents as JSON. Thus, to print all the installed styles and their +description in JSON, use the command:: + + $ pygmentize -L styles --json + The ``-H`` option will give you detailed information (the same that can be found in this documentation) about a lexer, formatter or filter. Usage is as follows:: |