diff --git a/ckanext/pygments/helpers.py b/ckanext/pygments/helpers.py index 28e3dc4..9f2f6fb 100644 --- a/ckanext/pygments/helpers.py +++ b/ckanext/pygments/helpers.py @@ -40,7 +40,7 @@ def pygment_preview(resource: dict[str, Any], theme: str) -> tuple[str, str]: else: data = resp.text - css_styles = HtmlFormatter(style=theme).get_style_defs(".highlight") + css_styles = HtmlFormatter(style=theme or "default").get_style_defs(".highlight") return ( highlight( diff --git a/ckanext/pygments/templates/pygment_form.html b/ckanext/pygments/templates/pygment_form.html index ea2eecd..aa14a7e 100644 --- a/ckanext/pygments/templates/pygment_form.html +++ b/ckanext/pygments/templates/pygment_form.html @@ -2,4 +2,4 @@ {{ form.input('file_url', id='field-file_url', label=_('File URL'), placeholder=_('eg. http://example.com/test.sql (if blank uses resource url)'), value=data.file_url, error=errors.file_url) }} -{{ form.select('theme', id='field-theme', label=_('Preview theme'), options=h.get_preview_theme_options(), selected=data.theme, error=errors.theme) }} +{{ form.select('theme', id='field-theme', label=_('Preview theme'), options=h.get_preview_theme_options(), selected=data.theme or "default", error=errors.theme) }}