File: README.md

package info (click to toggle)
python-ansible-pygments 0.1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: python: 487; sh: 23; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 1,685 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# [Pygments] lexer and style Ansible snippets

[![GitHub Actions CI/CD workflow](https://github.com/ansible-community/ansible-pygments/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/ansible-community/ansible-pygments/actions/workflows/ci-cd.yml)
[![Codecov badge](https://img.shields.io/codecov/c/github/ansible-community/ansible-pygments)](https://codecov.io/gh/ansible-community/ansible-pygments)

This project provides a [Pygments] lexer that is able to handle
[Ansible] output. It may be used anywhere Pygments is integrated.
The lexer is registered globally under the name `ansible-output`.

It also provides a [Pygments] style for tools needing to highlight
code snippets.

The code is licensed under the terms of the [BSD 2-Clause license].

## Using the lexer in [Sphinx]

Make sure this library in installed in the same env as your [Sphinx]
automation via `pip install ansible-pygments sphinx`. Then, you should
be able to use a lexer by its name `ansible-output` in the code blocks
of your RST documents. For example:

```rst
.. code-block:: ansible-output

    [WARNING]: Unable to find '/nosuchfile' in expected paths (use -vvvvv to see paths)

    ok: [localhost] => {
        "msg": ""
    }
```

## Using the style in [Sphinx]

It is possible to just set `ansible` in `conf.py` and it will "just
work", provided that this project is installed alongside [Sphinx] as
shown above.

```python
pygments_style = 'ansible'
```

[Ansible]: https://www.ansible.com/?utm_medium=github-or-pypi&utm_source=ansible-pygments--readme
[Pygments]: https://pygments.org
[Sphinx]: https://www.sphinx-doc.org
[BSD 2-Clause license]: https://opensource.org/licenses/BSD-2-Clause