Sync from SUSE:SLFO:Main python-jupyterlab-pygments revision 98f02af86828726a919f59c1a5ac21ef

This commit is contained in:
Adrian Schröter 2024-05-03 21:19:20 +02:00
commit 104ffee274
6 changed files with 242 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

72
Example.ipynb Normal file
View File

@ -0,0 +1,72 @@
{
"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": [
"mycode = \"\"\"\n",
"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",
" return f'<div class=\"highlight\">{html}</div>'\n",
"\"\"\"\n",
"exec(mycode)"
]
},
{
"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(mycode)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

BIN
jupyterlab_pygments-0.2.2-py2.py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,50 @@
-------------------------------------------------------------------
Thu Feb 2 17:16:28 UTC 2023 - Ben Greiner <code@bnavigator.de>
- Modify Example.ipynb because nbval 0.10 abolished saving the
input history
-------------------------------------------------------------------
Sun Dec 25 11:39:59 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Find the license in any installed sitelib: we might not have
python3 flavor (:backports)
-------------------------------------------------------------------
Mon Aug 1 20:29:07 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Update to v0.2.2
* no release notes
- Add labextensions subpackage
-------------------------------------------------------------------
Mon Nov 15 19:01:14 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Avoid buildcycle with test multibuild
-------------------------------------------------------------------
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>
- specfile:
* update copyright year
* be more specific in %files section
- update to version 0.1.1:
* no changelog available
-------------------------------------------------------------------
Wed Nov 13 19:11:00 UTC 2019 - Todd R <toddrme2178@gmail.com>
- Make python3-only because jupyterlab is python3-only
-------------------------------------------------------------------
Wed Jun 12 20:58:26 UTC 2019 - Todd R <toddrme2178@gmail.com>
- Initial version

View File

@ -0,0 +1,91 @@
#
# spec file
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
Name: python-jupyterlab-pygments%{psuffix}
Version: 0.2.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/py2.py3/j/jupyterlab-pygments/jupyterlab_pygments-%{version}-py2.py3-none-any.whl
# Slightly modified from https://github.com/jupyterlab/jupyterlab_pygments/blob/0.2.2/notebooks/Example.ipynb
Source1: Example.ipynb
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module pip}
BuildRequires: fdupes
BuildRequires: jupyter-rpm-macros
BuildRequires: python-rpm-macros
Requires: jupyter-jupyterlab-pygments = %{version}
Requires: python-pygments >= 2.4.1
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module jupyterlab-pygments = %{version}}
BuildRequires: %{python_module nbval}
BuildRequires: %{python_module pytest}
%endif
%python_subpackages
%description
This package contains a syntax coloring theme for pygments making use
of the JupyterLab CSS variables.
%package -n jupyter-jupyterlab-pygments
Summary: Pygments theme for jupyterlab -- Jupyterlab extension files
%description -n jupyter-jupyterlab-pygments
This package contains the Jupyterlab extension files for python-jupyterlab-pygments
%prep
%setup -q -c -T
%build
:
%if !%{with test}
%install
%pyproject_install %{SOURCE0}
%python_expand %fdupes %{buildroot}%{$python_sitelib}
find %{buildroot}%{_prefix} -path '*/site-packages/jupyterlab_pygments-%{version}.dist-info/LICENSE' -exec cp {} . ';' -quit
%endif
%if %{with test}
%check
%pytest --nbval-lax %{SOURCE1}
%endif
%if !%{with test}
%files %{python_files}
%license LICENSE
%{python_sitelib}/jupyterlab_pygments
%{python_sitelib}/jupyterlab_pygments-%{version}.dist-info
%files -n jupyter-jupyterlab-pygments
%{_jupyter_labextensions_dir3}/jupyterlab_pygments
%endif
%changelog