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.2.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.4.2-py3-none-any.whl (47.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ckanext_pygments-1.4.2.tar.gz
Algorithm Hash digest
SHA256 8a30fc79b9a9a1b179ddbeead776b11b7f52fbd26e2cbf17760f0b8fc13ae49a
MD5 2d8879f3833a9a47b653a4178e70e6a7
BLAKE2b-256 ac44ba3dfef7e721c1f8147fcfbefcce7202a76b1c1666a269b80a4978293c5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ckanext_pygments-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33b73c12caa1d82171a035ba302aadb4e9aa897c54ee4d90f86e0a1476b85677
MD5 3915913a62c63a434a5eeb6e0d237bb1
BLAKE2b-256 1642c6b66dfc0eb867c583cf00b53f0a8f25e515c43cf02392a9a101338e9098

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