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.4.1.tar.gz (43.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.4.1-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ckanext_pygments-1.4.1.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for ckanext_pygments-1.4.1.tar.gz
Algorithm Hash digest
SHA256 4a2d561ad7102c11f32b8164787659b89bde1e0b6f3143b81045964a201b02e1
MD5 b4f7f221580a13090490a65b3f6c5df9
BLAKE2b-256 b2af28a5c3dc12f2a175ee13ae6087c5c655ded3ded0a2ca6d5f78dd207e2b9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ckanext_pygments-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a327d9361e20fa5c6feed0524e988abd2d22bd59c3b98f50a8d41a4cd54f004
MD5 daeb4685bba11a721e086fc8421ba6ec
BLAKE2b-256 24dfad02341e9f0e963b2d4d435ed6036463bb74c4dd90fcc8391033f433cf9e

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