Accepting request 931416 from devel:languages:python:jupyter

- Update to 0.1.2
  * fix license metadata in setuptools
- check for errors in Example.ipynb with nbval (forwarded request 931415 from bnavigator)

OBS-URL: https://build.opensuse.org/request/show/931416
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-jupyterlab-pygments?expand=0&rev=4
This commit is contained in:
Dominique Leuenberger 2021-11-15 14:26:45 +00:00 committed by Git OBS Bridge
commit 370a72020f
5 changed files with 98 additions and 7 deletions

77
Example.ipynb Normal file
View File

@ -0,0 +1,77 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pygments import highlight\n",
"from pygments.lexers import PythonLexer\n",
"from pygments.formatters import HtmlFormatter\n",
"from jupyterlab_pygments import JupyterStyle"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class PythonCode:\n",
" def __init__(self, value):\n",
" self.value = value\n",
" \n",
" def _repr_html_(self, **kwargs):\n",
" formatter = HtmlFormatter(style=JupyterStyle)\n",
" html = highlight(self.value, PythonLexer(), formatter)\n",
" css = formatter.get_style_defs('.highlight')\n",
" return f'<style>{css}</style><div class=\"highlight\">{html}</div>'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Rendering the previous cell in HTML with Pygments and JupyterStyle respects the JupyterLab theme"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"PythonCode(In[2])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:19a0ccde7daddec638363cd3d60b63a4f6544c9181d65253317b2fb492a797b9
size 4169

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cfcda0873626150932f438eccf0f8bf22bfa92345b814890ab360d666b254146
size 4181

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Sun Nov 14 18:02:29 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Update to 0.1.2
* fix license metadata in setuptools
- check for errors in Example.ipynb with nbval
-------------------------------------------------------------------
Sat Apr 25 16:48:39 UTC 2020 - Arun Persaud <arun@gmx.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-jupyterlab-pygments
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -16,16 +16,20 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
Name: python-jupyterlab-pygments
Version: 0.1.1
Version: 0.1.2
Release: 0
Summary: Pygments theme for jupyterlab
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/jupyterlab/jupyterlab_pygments
Source: https://files.pythonhosted.org/packages/source/j/jupyterlab_pygments/jupyterlab_pygments-%{version}.tar.gz
Source1: https://raw.githubusercontent.com/jupyterlab/jupyterlab_pygments/%{version}/notebooks/Example.ipynb
BuildRequires: %{python_module nbval}
BuildRequires: %{python_module pygments >= 2.4.1}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@ -47,10 +51,13 @@ of the JupyterLab CSS variables.
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%pytest --nbval-lax %{SOURCE1}
%files %{python_files}
%license LICENSE
%doc README.md
%{python_sitelib}/jupyterlab_pygments
%{python_sitelib}/jupyterlab_pygments-%{version}-py*.egg-info
%{python_sitelib}/jupyterlab_pygments-%{version}*-info
%changelog