Skip to main content

Provides previews with syntax highlight for multiple formats

Project description

ckanext-pygments

This extension provides a preview with syntax highlight for multiple text resources formats.

Preview

Installation

Install from source

pip install -e .

Or use pip

pip install ckanext-pygments

Enable the plugin and the view in your CKAN config file:

ckan.plugins = pygments_view
ckan.views.default_views = pygments_view

Caching

There is a caching mechanism implemented in this extension. It is disabled by default. To enable it, set ckanext.pygments.cache.enable to True. You can also set the time to live for the cache in seconds with ckanext.pygments.cache.ttl. The default is 7200 seconds (2 hours). You can also set the maximum size of the resource to cache in bytes with ckanext.pygments.cache.resouce_max_size. The default is 20MB.

Why cache is disabled by default?

We use Redis for caching and it uses memory. If you have a lot of resources and they are big, you can run out of memory. That's why it is disabled by default. It's still debatable if we need cache at all. Big resource processed with pygments will be even bigger. So we can have a lot of memory usage. But if we have a lot of resources and many users access it, we can save a lot of time on processing.

Admin configuration page

If you're using the ckanext-admin-panel extension, you can configure the pygments settings from the admin panel. Otherwise, you can configure it in the ckan.ini file.

Config settings

See config declaration file

Tests

To run the tests, do:

pytest --ckan-ini=test.ini

License

AGPL

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

ckanext_pygments-1.3.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

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

ckanext_pygments-1.3.0-py3-none-any.whl (47.4 kB view details)

Uploaded Python 3

File details

Details for the file ckanext_pygments-1.3.0.tar.gz.

File metadata

  • Download URL: ckanext_pygments-1.3.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for ckanext_pygments-1.3.0.tar.gz
Algorithm Hash digest
SHA256 e663d8923f7d7abf9f52fcce8855a335e4eb82e54ed6d6b03bf9e690851d29ca
MD5 3b7872bc03d519992007617aebf94257
BLAKE2b-256 27b7946222ee7cb6e95248d96bfedb3f1581d06fddde66c029024e0ac30422f5

See more details on using hashes here.

File details

Details for the file ckanext_pygments-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ckanext_pygments-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60e4f9bb1eede9b300ed9a593836af10bfb4475c13962ef450197e9e52787e5a
MD5 d813c6420f6db0538ed05e50e28c331a
BLAKE2b-256 3fc9034e1d3cbd45691de609587dad9a6054beeecf611d884bdee2990630ebdc

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