Skip to main content

Pygments style for Ashen

Project description

Pygments Ashen

This repository contains the Pygments style plugin for the Ashen theme. Available as the pygments-ashen package on PyPI for use in your Python projects, or with the Pygments CLI tool. The actual name of the style within pygments is ashen.

How To Use

The following shows how to use the style with uv, which is currently the cleanest way to manage Python projects and libraries. You may, of course, install the package into a virtual environment with pip, if you wish:

pip install pygments-ashen

Pygments CLI

Third-party Pygments styles are Python packages that must be available in the environment pygments is running in. For example, you can use uv to create a one-off environment for a single command:

uv run --with 'pygments-ashen,pygments' \
pygmentize -O full,style=ashen \
-l python -f html foobar.py > foobar.html

The above command invokes pygmentize with the pygments-ashen and pygments dependencies available, and renders the file foobar.py in HTML format with the Ashen theme applied.

In Your Projects

If your project uses Pygments for code highlighting, you can easily add support for Ashen. The pygments-ashen package must be installed in the project environment:

uv add pygments-ashen

Then, you can use ashen as the style in Pygments formatters. Here's an example from Zona. This code renders a Markdown code block in HTML with Ashen highlighting, using the marko library:

# method part of subclass of marko.html_renderer.HTMLRenderer
@override
def render_fenced_code(self, element: FencedCode):
    # pygments expects a single string, not a list of lines
    code = "".join(child.children for child in element.children)
    # fallback to "text" if no language specified
    lang = element.lang or "text"

    # load the correct pygments lexer
    try:
        lexer = get_lexer_by_name(lang, stripall=False)
    except Exception:
        lexer = TextLexer(stripall=False)

    # use the "ashen" style, requires pygments-ashen package
    formatter = HtmlFormatter(style="ashen", nowrap=True, noclasses=True)
    # highlight the code
    highlighted = highlight(code, lexer, formatter)

    # return rendered code block
    return (
        f'<pre class="code-block language-{lang}">'
        f"<code>{highlighted}</code></pre>"
    )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygments_ashen-0.1.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygments_ashen-0.1.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pygments_ashen-0.1.3.tar.gz.

File metadata

  • Download URL: pygments_ashen-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.18

File hashes

Hashes for pygments_ashen-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2c69a931741f98fca531ef11d17bf690547f14a4382ec0fed7c7715a03aeaaf7
MD5 6599cb3f55e992061937382756da9bea
BLAKE2b-256 0da4e2eeeeb8211b3425eeeeaa49a1d94a3c8bfd6046ce2723897fe778f03198

See more details on using hashes here.

File details

Details for the file pygments_ashen-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pygments_ashen-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c5553a9302d581743d928b834cae8f3f62ee52a7fd8b72b73f04796a1c71cef3
MD5 473d1ddf0b0ec35cd402070db58f7618
BLAKE2b-256 be2dd9b1b57c4cd394459d6b1456efc6cdaba8c9b8b1fa4d9023c69ad846c7cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page