Skip to content

Commit f0b9a18

Browse files
committed
1 parent 6d00229 commit f0b9a18

File tree

18 files changed

+510
-80
lines changed

18 files changed

+510
-80
lines changed

.doctrees/docs/lexers.doctree

29.9 KB
Binary file not shown.
4.02 KB
Binary file not shown.

.doctrees/environment.pickle

38.1 KB
Binary file not shown.
Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,54 @@
1-
Interactive terminal/shell sessions
2-
-----------------------------------
1+
=================
2+
Terminal sessions
3+
=================
34

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

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

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

14-
.. code-block:: console
1513

16-
[any@any]$ ls -lh
17-
[any@any]# ls -lh
18-
[any@any]% ls -lh
19-
$ ls -lh
20-
# ls -lh
21-
% ls -lh
22-
> ls -lh
14+
Operating system shells
15+
-----------------------
2316

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

26-
.. code-block:: doscon
20+
They are typically named ``<shell> Session``.
2721

28-
[any]> dir
29-
> dir
30-
More? dir
3122

32-
* **Tcsh Session** (tcshcon):
23+
Interactive consoles
24+
--------------------
3325

34-
.. code-block:: tcshcon
26+
Similarly to systems shells, Pygments recognize a variety of interactive
27+
language sessions.
3528

36-
(any)> ls -lh
37-
? ls -lh
29+
Their IDs typically follow the ``<language>-console`` or
30+
``<language>-repl`` pattern.
3831

39-
* **PowerShell Session** (ps1con):
4032

41-
.. code-block:: ps1con
33+
Generic output
34+
--------------
4235

43-
PS[any]> Get-ChildItem
44-
PS> Get-ChildItem
45-
>> Get-ChildItem
36+
To display standalone terminal output and keep styling consistent, you can use
37+
the generic ``output`` lexer.
4638

39+
40+
ANSI rendering
41+
--------------
42+
43+
In all the lexers above, the command results are parsed as generic output.
44+
Which means they are rendered as-is, without any styling applied, for example by ANSI codes.
45+
46+
Here is a couple of third-party projects covering this use-case:
47+
48+
- `pygments-ansi-color
49+
<https://github.com/chriskuehl/pygments-ansi-color>`_: implements
50+
a new lexer and formatter to parse and render pure ANSI content.
51+
- `Click Extra <https://github.com/kdeldycke/click-extra>`_: adds
52+
`ANSI-capable lexers
53+
<https://kdeldycke.github.io/click-extra/pygments.html#ansi-language-lexers>`_
54+
for each language listed above.

_static/pyodide/distutils.tar

0 Bytes
Binary file not shown.
167 Bytes
Binary file not shown.

_static/pyodide/pyodide.asm.data

-8.47 KB
Binary file not shown.

_static/pyodide/pyodide.asm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_static/pyodide/pyodide.asm.wasm

0 Bytes
Binary file not shown.

_static/pyodide/pyodide_py.tar

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)