Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Anteru committed May 18, 2024
1 parent 6d00229 commit f0b9a18
Show file tree
Hide file tree
Showing 18 changed files with 510 additions and 80 deletions.
Binary file modified .doctrees/docs/lexers.doctree
Binary file not shown.
Binary file modified .doctrees/docs/terminal-sessions.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
70 changes: 39 additions & 31 deletions _sources/docs/terminal-sessions.rst.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
Interactive terminal/shell sessions
-----------------------------------
=================
Terminal sessions
=================

To highlight an interactive terminal or shell session, prefix your code snippet
with a specially formatted prompt.
Pygments support the parsing and highlighting of terminal sessions, like
command-line shells, interactive consoles and language `REPL
<https://en.wikipedia.org/wiki/Read–eval–print_loop>`_.

Supported shells with examples are shown below. In each example, prompt parts in
brackets ``[any]`` represent optional parts of the prompt, and prompt parts
without brackets or in parenthesis ``(any)`` represent required parts of the
prompt.
They are typically command lines or code, mixed with generic output.

* **Bash Session** (console, shell-session):
Examples for each can be found in the :doc:`lexer <lexers>` documentation.

.. code-block:: console

[any@any]$ ls -lh
[any@any]# ls -lh
[any@any]% ls -lh
$ ls -lh
# ls -lh
% ls -lh
> ls -lh
Operating system shells
-----------------------

* **MSDOS Session** (doscon):
These lexers are expecting a prompt to identify user input. So to highlight a
shell session, prefix your code snippet with a specially formatted prompt.

.. code-block:: doscon
They are typically named ``<shell> Session``.

[any]> dir
> dir
More? dir

* **Tcsh Session** (tcshcon):
Interactive consoles
--------------------

.. code-block:: tcshcon
Similarly to systems shells, Pygments recognize a variety of interactive
language sessions.

(any)> ls -lh
? ls -lh
Their IDs typically follow the ``<language>-console`` or
``<language>-repl`` pattern.

* **PowerShell Session** (ps1con):

.. code-block:: ps1con
Generic output
--------------

PS[any]> Get-ChildItem
PS> Get-ChildItem
>> Get-ChildItem
To display standalone terminal output and keep styling consistent, you can use
the generic ``output`` lexer.


ANSI rendering
--------------

In all the lexers above, the command results are parsed as generic output.
Which means they are rendered as-is, without any styling applied, for example by ANSI codes.

Here is a couple of third-party projects covering this use-case:

- `pygments-ansi-color
<https://github.com/chriskuehl/pygments-ansi-color>`_: implements
a new lexer and formatter to parse and render pure ANSI content.
- `Click Extra <https://github.com/kdeldycke/click-extra>`_: adds
`ANSI-capable lexers
<https://kdeldycke.github.io/click-extra/pygments.html#ansi-language-lexers>`_
for each language listed above.
Binary file modified _static/pyodide/distutils.tar
Binary file not shown.
Binary file modified _static/pyodide/pygments-2.18.0-py3-none-any.whl
Binary file not shown.
Binary file modified _static/pyodide/pyodide.asm.data
Binary file not shown.
2 changes: 1 addition & 1 deletion _static/pyodide/pyodide.asm.js

Large diffs are not rendered by default.

Binary file modified _static/pyodide/pyodide.asm.wasm
Binary file not shown.
Binary file modified _static/pyodide/pyodide_py.tar
Binary file not shown.
Binary file modified _static/pyodide/test.tar
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<link rel="icon" href="../../_static/favicon.ico"/>
<link rel="index" title="Index" href="../../genindex/" />
<link rel="search" title="Search" href="../../search/" />
<link rel="next" title="Interactive terminal/shell sessions" href="../terminal-sessions/" />
<link rel="next" title="Terminal sessions" href="../terminal-sessions/" />
<link rel="prev" title="Builtin Tokens" href="../tokens/" />
<link href='https://fonts.googleapis.com/css?family=PT+Sans:300,400,700'
rel='stylesheet' type='text/css'>
Expand Down Expand Up @@ -159,7 +159,7 @@ <h4>Previous topic</h4>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="../terminal-sessions/"
title="next chapter">Interactive terminal/shell sessions</a></p>
title="next chapter">Terminal sessions</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h1>Pygments documentation<a class="headerlink" href="#pygments-documentation" t
<li class="toctree-l1"><a class="reference internal" href="unicode/">Unicode and Encodings</a></li>
<li class="toctree-l1"><a class="reference internal" href="tokens/">Builtin Tokens</a></li>
<li class="toctree-l1"><a class="reference internal" href="api/">The full Pygments API</a></li>
<li class="toctree-l1"><a class="reference internal" href="terminal-sessions/">Interactive terminal/shell sessions</a></li>
<li class="toctree-l1"><a class="reference internal" href="terminal-sessions/">Terminal sessions</a></li>
</ul>
</div>
<p><strong>Hacking with Pygments</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions docs/lexerdevelopment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<link rel="index" title="Index" href="../../genindex/" />
<link rel="search" title="Search" href="../../search/" />
<link rel="next" title="Write your own formatter" href="../formatterdevelopment/" />
<link rel="prev" title="Interactive terminal/shell sessions" href="../terminal-sessions/" />
<link rel="prev" title="Terminal sessions" href="../terminal-sessions/" />
<link href='https://fonts.googleapis.com/css?family=PT+Sans:300,400,700'
rel='stylesheet' type='text/css'>

Expand Down Expand Up @@ -105,7 +105,7 @@ <h3><a href="../../">Table of Contents</a></h3>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="../terminal-sessions/"
title="previous chapter">Interactive terminal/shell sessions</a></p>
title="previous chapter">Terminal sessions</a></p>
</div>
<div>
<h4>Next topic</h4>
Expand Down
Loading

0 comments on commit f0b9a18

Please sign in to comment.