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.
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
Tests
To run the tests, do:
pytest --ckan-ini=test.ini
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e663d8923f7d7abf9f52fcce8855a335e4eb82e54ed6d6b03bf9e690851d29ca
|
|
| MD5 |
3b7872bc03d519992007617aebf94257
|
|
| BLAKE2b-256 |
27b7946222ee7cb6e95248d96bfedb3f1581d06fddde66c029024e0ac30422f5
|
File details
Details for the file ckanext_pygments-1.3.0-py3-none-any.whl.
File metadata
- Download URL: ckanext_pygments-1.3.0-py3-none-any.whl
- Upload date:
- Size: 47.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e4f9bb1eede9b300ed9a593836af10bfb4475c13962ef450197e9e52787e5a
|
|
| MD5 |
d813c6420f6db0538ed05e50e28c331a
|
|
| BLAKE2b-256 |
3fc9034e1d3cbd45691de609587dad9a6054beeecf611d884bdee2990630ebdc
|