Benjamin Greiner 2025-02-27 12:57:55 +00:00 committed by Git OBS Bridge
commit 5b8663c225
7 changed files with 272 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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

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>

View File

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

View File

@ -0,0 +1,72 @@
-------------------------------------------------------------------
Thu Feb 27 12:52:36 UTC 2025 - ecsos <ecsos@opensuse.org>
- Add %{?sle15_python_module_pythons}
-------------------------------------------------------------------
Thu May 9 06:59:50 UTC 2024 - Daniel Garcia <daniel.garcia@suse.com>
- Build from source not whl from pypi.
-------------------------------------------------------------------
Thu Mar 7 11:17:46 UTC 2024 - Ben Greiner <code@bnavigator.de>
- Skip testing with python39: no longer supported since ipython
8.19 (nbval)
-------------------------------------------------------------------
Sat Dec 23 20:13:55 UTC 2023 - Ben Greiner <code@bnavigator.de>
- Update to 0.3.0
* no release notes
-------------------------------------------------------------------
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,98 @@
#
# spec file for package python-jupyterlab-pygments
#
# Copyright (c) 2024 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
%define skip_python39 1
%else
%define psuffix %{nil}
%bcond_with test
%endif
%define distversion 0.3
%{?sle15_python_module_pythons}
Name: python-jupyterlab-pygments%{psuffix}
Version: 0.3.0
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
# Slightly modified from https://github.com/jupyterlab/jupyterlab_pygments/blob/0.2.2/notebooks/Example.ipynb
Source1: Example.ipynb
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module hatch-jupyter-builder}
BuildRequires: %{python_module hatch-nodejs-version}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
BuildRequires: fdupes
BuildRequires: jupyter-rpm-macros
BuildRequires: python-rpm-macros
Requires: jupyter-jupyterlab-pygments = %{version}
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
Requires: python3dist(jupyterlab-pygments) = %{distversion}
%description -n jupyter-jupyterlab-pygments
This package contains the Jupyterlab extension files for python-jupyterlab-pygments
%prep
%autosetup -p1 -n jupyterlab_pygments-%{version}
%build
%{pyproject_wheel}
%if !%{with test}
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
find %{buildroot}%{_prefix} -path '*/site-packages/jupyterlab_pygments-%{version}.dist-info/licenses/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