Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-nbconvert for
openSUSE:Factory checked in at 2022-02-21 17:46:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-nbconvert (Old)
and /work/SRC/openSUSE:Factory/.python-nbconvert.new.1958 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-nbconvert"
Mon Feb 21 17:46:10 2022 rev:11 rq:956041 version:6.4.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-nbconvert/python-nbconvert.changes
2022-01-08 23:23:45.058238096 +0100
+++
/work/SRC/openSUSE:Factory/.python-nbconvert.new.1958/python-nbconvert.changes
2022-02-21 17:46:42.795596048 +0100
@@ -1,0 +2,17 @@
+Sat Feb 19 03:07:52 UTC 2022 - Arun Persaud <[email protected]>
+
+- update to version 6.4.2:
+ * Adding theme support for WebPDF exporter (#1718)
+ * Add option to embed_images in Markdown cells (#1717)
+ * HTMLExporter: Add theme alias and docs (#1716)
+ * Add basic support for federated labextensions themes (#1703)
+ * Always hide the collapser element (#1712)
+ * Raise pyppeteer requirement to >=1,<1.1 (#1711)
+
+- changes from version 6.4.1:
+ * CodeMirror style bleed fix (#1710)
+ * Fix DOM structure of markdown cells in lab template (#1709)
+ * Fix styling regression (#1708)
+ * Handle needs_background cell metadata (#1704)
+
+-------------------------------------------------------------------
Old:
----
nbconvert-6.4.0.tar.gz
New:
----
nbconvert-6.4.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-nbconvert.spec ++++++
--- /var/tmp/diff_new_pack.hxhX88/_old 2022-02-21 17:46:43.963596396 +0100
+++ /var/tmp/diff_new_pack.hxhX88/_new 2022-02-21 17:46:43.967596397 +0100
@@ -24,17 +24,15 @@
%define psuffix %{nil}
%bcond_with test
%endif
-
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
-
%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
Name: python-nbconvert%{psuffix}
-Version: 6.4.0
+Version: 6.4.2
Release: 0
Summary: Conversion of Jupyter Notebooks
License: BSD-3-Clause
@@ -62,19 +60,19 @@
Requires: python-pandocfilters >= 1.4.1
Requires: python-testpath
Requires: python-traitlets >= 5.0
-%if %{with libalternatives}
-Requires: alts
-BuildRequires: alts
-%else
-Requires(post): update-alternatives
-Requires(postun):update-alternatives
-%endif
Recommends: pandoc
Recommends: python-tornado >= 4.0
Suggests: %{name}-latex
Provides: python-jupyter_nbconvert = %{version}
Obsoletes: python-jupyter_nbconvert < %{version}
BuildArch: noarch
+%if %{with libalternatives}
+BuildRequires: alts
+Requires: alts
+%else
+Requires(post): update-alternatives
+Requires(postun):update-alternatives
+%endif
%if %{with test}
BuildRequires: %{python_module ipykernel}
BuildRequires: %{python_module ipywidgets >= 7}
++++++ nbconvert-6.4.0.tar.gz -> nbconvert-6.4.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/PKG-INFO new/nbconvert-6.4.2/PKG-INFO
--- old/nbconvert-6.4.0/PKG-INFO 2022-01-03 21:33:28.199606700 +0100
+++ new/nbconvert-6.4.2/PKG-INFO 2022-02-10 00:02:54.066899800 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: nbconvert
-Version: 6.4.0
+Version: 6.4.2
Summary: Converting Jupyter Notebooks
Home-page: https://jupyter.org
Author: Jupyter Development Team
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/docs/source/usage.rst
new/nbconvert-6.4.2/docs/source/usage.rst
--- old/nbconvert-6.4.0/docs/source/usage.rst 2022-01-03 21:32:16.283277500
+0100
+++ new/nbconvert-6.4.2/docs/source/usage.rst 2022-02-10 00:01:26.782388700
+0100
@@ -51,7 +51,13 @@
- ``--template lab`` (default)
A full static HTML render of the notebook.
- This looks very similar to the jupyter lab interactive view.
+ This looks very similar to the JupyterLab interactive view.
+
+ The lab template supports the extra ``--theme`` option, which defaults to
``light``.
+ This extra option not only allows you to use the default ``light`` or
``dark`` themes provided by JupyterLab,
+ but it allows you to use custom themes. For example:
+
+ ``pip install jupyterlab-miami-nights`` then ``--theme
jupyterlab_miami_nights``.
- ``--template classic``
@@ -61,6 +67,10 @@
Base HTML, rendering with minimal structure and styles.
+ - ``--embed-images``
+
+ If this option is provided, embed images as base64 urls in the resulting
HTML file.
+
.. _convert_latex:
LaTeX
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/nbconvert/_version.py
new/nbconvert-6.4.2/nbconvert/_version.py
--- old/nbconvert-6.4.0/nbconvert/_version.py 2022-01-03 21:32:28.269111000
+0100
+++ new/nbconvert-6.4.2/nbconvert/_version.py 2022-02-10 00:02:42.110830000
+0100
@@ -1,4 +1,4 @@
-version_info = (6, 4, 0)
+version_info = (6, 4, 2)
pre_info = ''
dev_info = ''
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/nbconvert/exporters/html.py
new/nbconvert-6.4.2/nbconvert/exporters/html.py
--- old/nbconvert-6.4.0/nbconvert/exporters/html.py 2022-01-03
21:32:16.284103900 +0100
+++ new/nbconvert-6.4.2/nbconvert/exporters/html.py 2022-02-10
00:01:26.782388700 +0100
@@ -6,7 +6,9 @@
import os
import mimetypes
+import json
import base64
+from pathlib import Path
from traitlets import default, Unicode, Bool
from traitlets.config import Config
@@ -27,6 +29,58 @@
from .templateexporter import TemplateExporter
+def find_lab_theme(theme_name):
+ """
+ Find a JupyterLab theme location by name.
+
+ Parameters
+ ----------
+ theme_name : str
+ The name of the labextension theme you want to find.
+
+ Raises
+ ------
+ ValueError
+ If the theme was not found, or if it was not specific enough.
+
+ Returns
+ -------
+ theme_name: str
+ Full theme name (with scope, if any)
+ labextension_path : Path
+ The path to the found labextension on the system.
+ """
+ paths = jupyter_path('labextensions')
+
+ matching_themes = []
+ theme_path = None
+ for path in paths:
+ for (dirpath, dirnames, filenames) in os.walk(path):
+ # If it's a federated labextension that contains themes
+ if 'package.json' in filenames and 'themes' in dirnames:
+ # TODO Find the theme name in the JS code instead?
+ # TODO Find if it's a light or dark theme?
+ with open(Path(dirpath) / 'package.json', 'r',
encoding="utf-8") as fobj:
+ labext_name = json.loads(fobj.read())['name']
+
+ if labext_name == theme_name or theme_name in
labext_name.split('/'):
+ matching_themes.append(labext_name)
+
+ full_theme_name = labext_name
+ theme_path = Path(dirpath) / 'themes' / labext_name
+
+ if len(matching_themes) == 0:
+ raise ValueError(f'Could not find lab theme "{theme_name}"')
+
+ if len(matching_themes) > 1:
+ raise ValueError(
+ f'Found multiple themes matching "{theme_name}":
{matching_themes}. '
+ 'Please be more specific about which theme you want to use.'
+ )
+
+ return full_theme_name, theme_path
+
+
class HTMLExporter(TemplateExporter):
"""
Exports a basic HTML document. This exporter assists with the export of
@@ -89,10 +143,14 @@
def _template_name_default(self):
return 'lab'
- theme = Unicode('light',
- help='Template specific theme(e.g. the JupyterLab CSS
theme for the lab template)'
+ theme = Unicode(
+ 'light',
+ help="Template specific theme(e.g. the name of a JupyterLab CSS theme
distributed as prebuilt extension for the lab template)"
).tag(config=True)
+ embed_images = Bool(False,
+ help="Whether or not to embed images as base64 in markdown
cells.").tag(config=True)
+
output_mimetype = 'text/html'
@property
@@ -123,9 +181,16 @@
"""Markdown to HTML filter respecting the anchor_link_text setting"""
cell = context.get('cell', {})
attachments = cell.get('attachments', {})
- renderer = IPythonRenderer(escape=False, attachments=attachments,
- anchor_link_text=self.anchor_link_text,
-
exclude_anchor_links=self.exclude_anchor_links)
+ path = context.get('resources', {}).get('metadata', {}).get('path', '')
+
+ renderer = IPythonRenderer(
+ escape=False,
+ attachments=attachments,
+ embed_images=self.embed_images,
+ path=path,
+ anchor_link_text=self.anchor_link_text,
+ exclude_anchor_links=self.exclude_anchor_links
+ )
return MarkdownWithMath(renderer=renderer).render(source)
def default_filters(self):
@@ -150,6 +215,30 @@
code = """<style type="text/css">\n%s</style>""" %
(env.loader.get_source(env, name)[0])
return jinja2.Markup(code)
+ def resources_include_lab_theme(name):
+ # Try to find the theme with the given name, looking through the
labextensions
+ _, theme_path = find_lab_theme(name)
+
+ with open(theme_path / 'index.css', 'r') as file:
+ data = file.read()
+
+ # Embed assets (fonts, images...)
+ for asset in os.listdir(theme_path):
+ local_url = "url({})".format(Path(asset).as_posix())
+
+ if local_url in data:
+ mime_type = mimetypes.guess_type(asset)[0]
+
+ # Replace asset url by a base64 dataurl
+ with open(theme_path / asset, 'rb') as assetfile:
+ base64_data = base64.b64encode(assetfile.read())
+ base64_data = base64_data.replace(b'\n',
b'').decode('ascii')
+
+ data = data.replace(local_url,
'url(data:{};base64,{})'.format(mime_type, base64_data))
+
+ code = """<style type="text/css">\n%s</style>""" % data
+ return jinja2.Markup(code)
+
def resources_include_js(name):
env = self.environment
code = """<script>\n%s</script>""" % (env.loader.get_source(env,
name)[0])
@@ -178,9 +267,11 @@
data = data.replace(b'\n', b'').decode('ascii')
src = 'data:{mime_type};base64,{data}'.format(mime_type=mime_type,
data=data)
return jinja2.Markup(src)
+
resources = super()._init_resources(resources)
resources['theme'] = self.theme
resources['include_css'] = resources_include_css
+ resources['include_lab_theme'] = resources_include_lab_theme
resources['include_js'] = resources_include_js
resources['include_url'] = resources_include_url
resources['require_js_url'] = self.require_js_url
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/nbconvert/exporters/webpdf.py
new/nbconvert-6.4.2/nbconvert/exporters/webpdf.py
--- old/nbconvert-6.4.0/nbconvert/exporters/webpdf.py 2022-01-03
21:32:16.288179200 +0100
+++ new/nbconvert-6.4.2/nbconvert/exporters/webpdf.py 2022-02-10
00:01:26.782388700 +0100
@@ -87,11 +87,12 @@
args=args
)
page = await browser.newPage()
+ await page.emulateMedia('screen')
await page.waitFor(100)
await page.goto(f'file://{temp_file.name}',
waitUntil='networkidle0')
await page.waitFor(100)
- pdf_params = {}
+ pdf_params = {'printBackground': True}
if not self.paginate:
# Floating point precision errors cause the printed
# PDF from spilling over a new page by a pixel fraction.
@@ -107,11 +108,10 @@
width = dimensions['width']
height = dimensions['height']
# 200 inches is the maximum size for Adobe Acrobat Reader.
- pdf_params = {
+ pdf_params.update({
'width': min(width, 200 * 72),
'height': min(height, 200 * 72),
- 'printBackground': True,
- }
+ })
pdf_data = await page.pdf(pdf_params)
await browser.close()
@@ -154,3 +154,4 @@
resources['output_extension'] = '.pdf'
return pdf_data, resources
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/nbconvert-6.4.0/nbconvert/filters/markdown_mistune.py
new/nbconvert-6.4.2/nbconvert/filters/markdown_mistune.py
--- old/nbconvert-6.4.0/nbconvert/filters/markdown_mistune.py 2022-01-03
21:32:16.289050800 +0100
+++ new/nbconvert-6.4.2/nbconvert/filters/markdown_mistune.py 2022-02-10
00:01:26.782388700 +0100
@@ -8,6 +8,9 @@
from __future__ import print_function
+import base64
+import os
+import mimetypes
import re
from functools import partial
@@ -28,6 +31,10 @@
from nbconvert.filters.strings import add_anchor
+class InvalidNotebook(Exception):
+ pass
+
+
class MathBlockGrammar(mistune.BlockGrammar):
"""This defines a single regex comprised of the different patterns that
identify math content spanning multiple lines. These are used by the
@@ -158,12 +165,15 @@
"""
attachments = self.options.get('attachments', {})
attachment_prefix = 'attachment:'
+ embed_images = self.options.get('embed_images', False)
+ path = self.options.get('path', '')
+
if src.startswith(attachment_prefix):
name = src[len(attachment_prefix):]
-
- if not name in attachments:
+
+ if name not in attachments:
raise InvalidNotebook("missing attachment: {}".format(name))
-
+
attachment = attachments[name]
# we choose vector over raster, and lossless over lossy
preferred_mime_types = ['image/svg+xml', 'image/png', 'image/jpeg']
@@ -175,6 +185,18 @@
mime_type = preferred_mime_type
data = attachment[mime_type]
src = 'data:' + mime_type + ';base64,' + data
+
+ elif embed_images:
+ image_path = os.path.join(path, src)
+ if os.path.exists(image_path):
+ with open(image_path, 'rb') as fobj:
+ mime_type = mimetypes.guess_type(image_path)[0]
+
+ base64_data = base64.b64encode(fobj.read())
+ base64_data = base64_data.replace(b'\n',
b'').decode('ascii')
+
+ src = 'data:{};base64,{}'.format(mime_type, base64_data)
+
return super().image(src, title, text)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/nbconvert/nbconvertapp.py
new/nbconvert-6.4.2/nbconvert/nbconvertapp.py
--- old/nbconvert-6.4.0/nbconvert/nbconvertapp.py 2022-01-03
21:32:16.290283700 +0100
+++ new/nbconvert-6.4.2/nbconvert/nbconvertapp.py 2022-02-10
00:01:26.786388600 +0100
@@ -26,8 +26,8 @@
from traitlets.utils.importstring import import_item
+from .filters.markdown_mistune import InvalidNotebook # noqa For backward
compatibility
from .exporters.base import get_export_names, get_exporter
-from .exporters.templateexporter import TemplateExporter
from nbconvert import exporters, preprocessors, writers, postprocessors,
__version__
from .utils.base import NbConvertBase
from .utils.exceptions import ConversionException
@@ -55,6 +55,7 @@
'to' : 'NbConvertApp.export_format',
'template' : 'TemplateExporter.template_name',
'template-file' : 'TemplateExporter.template_file',
+ 'theme' : 'HTMLExporter.theme',
'writer' : 'NbConvertApp.writer_class',
'post': 'NbConvertApp.postprocessor_class',
'output': 'NbConvertApp.output_base',
@@ -148,7 +149,14 @@
'exclude_input': False,
}
},
- """Shows code input. This is flag is only useful for dejavu users."""
+ """Shows code input. This flag is only useful for dejavu users."""
+ ),
+ 'embed-images' : (
+ {'HTMLExporter' : {
+ 'embed_images': True,
+ }
+ },
+ """Embed the images as base64 dataurls in the output. This flag is
only useful for the HTML/WebPDF/Slides exports."""
),
})
@@ -595,8 +603,6 @@
def default_export_format(self):
return 'html'
-class InvalidNotebook(Exception):
- pass
#-----------------------------------------------------------------------------
# Main entry point
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbconvert-6.4.0/setup.py new/nbconvert-6.4.2/setup.py
--- old/nbconvert-6.4.0/setup.py 2022-01-03 21:32:16.300120400 +0100
+++ new/nbconvert-6.4.2/setup.py 2022-02-10 00:01:26.786388600 +0100
@@ -227,7 +227,7 @@
'nbclient>=0.5.0,<0.6.0'
]
-pyppeteer_req = 'pyppeteer==0.2.6'
+pyppeteer_req = 'pyppeteer>=1,<1.1'
extra_requirements = {
'test': [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/nbconvert-6.4.0/share/jupyter/nbconvert/templates/lab/base.html.j2
new/nbconvert-6.4.2/share/jupyter/nbconvert/templates/lab/base.html.j2
--- old/nbconvert-6.4.0/share/jupyter/nbconvert/templates/lab/base.html.j2
2022-01-03 21:32:16.302431300 +0100
+++ new/nbconvert-6.4.2/share/jupyter/nbconvert/templates/lab/base.html.j2
2022-01-26 15:52:41.937810000 +0100
@@ -89,7 +89,10 @@
{% endblock output %}
{% block markdowncell scoped %}
+<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell">
<div class="jp-Cell-inputWrapper">
+<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
+</div>
<div class="jp-InputArea jp-Cell-inputArea">
{%- if resources.global_content_filter.include_input_prompt-%}
{{ self.empty_in_prompt() }}
@@ -99,6 +102,7 @@
</div>
</div>
</div>
+</div>
{%- endblock markdowncell %}
{% block unknowncell scoped %}
@@ -176,9 +180,17 @@
{%- if height is not none %}
height={{ height }}
{%- endif %}
+class="
{%- if output | get_metadata('unconfined', 'image/png') %}
-class="unconfined"
+unconfined
+{%- endif %}
+{%- if output | get_metadata('needs_background', 'image/png') == 'light' %}
+jp-needs-light-background
{%- endif %}
+{%- if output | get_metadata('needs_background', 'image/png') == 'dark' %}
+jp-needs-dark-background
+{%- endif %}
+"
>
</div>
{%- endblock data_png %}
@@ -198,9 +210,17 @@
{%- if height is not none %}
height={{ height }}
{%- endif %}
+class="
{%- if output | get_metadata('unconfined', 'image/jpeg') %}
-class="unconfined"
+unconfined
+{%- endif %}
+{%- if output | get_metadata('needs_background', 'image/jpeg') == 'light' %}
+jp-needs-light-background
+{%- endif %}
+{%- if output | get_metadata('needs_background', 'image/jpeg') == 'dark' %}
+jp-needs-dark-background
{%- endif %}
+"
>
</div>
{%- endblock data_jpg %}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/nbconvert-6.4.0/share/jupyter/nbconvert/templates/lab/index.html.j2
new/nbconvert-6.4.2/share/jupyter/nbconvert/templates/lab/index.html.j2
--- old/nbconvert-6.4.0/share/jupyter/nbconvert/templates/lab/index.html.j2
2022-01-03 21:32:16.302593700 +0100
+++ new/nbconvert-6.4.2/share/jupyter/nbconvert/templates/lab/index.html.j2
2022-02-10 00:01:26.786388600 +0100
@@ -37,10 +37,17 @@
{{ resources.include_css("static/index.css") }}
{% if resources.theme == 'dark' %}
{{ resources.include_css("static/theme-dark.css") }}
-{% else %}
+{% elif resources.theme == 'light' %}
{{ resources.include_css("static/theme-light.css") }}
+{% else %}
+ {{ resources.include_lab_theme(resources.theme) }}
{% endif %}
<style type="text/css">
+/* Force rendering true colors when outputing to pdf */
+* {
+ -webkit-print-color-adjust: exact;
+}
+
/* Misc */
a.anchor-link {
display: none;
@@ -59,6 +66,11 @@
overflow: hidden;
}
+.CodeMirror pre {
+ margin: 0;
+ padding: 0;
+}
+
/* Using table instead of flexbox so that we can use break-inside property */
/* CSS rules under this comment should not be required anymore after we move
to the JupyterLab 4.0 CSS */
@@ -97,11 +109,12 @@
width: 100%;
}
-@media print {
- .jp-Collapser {
- display: none;
- }
+/* Hiding the collapser by default */
+.jp-Collapser {
+ display: none;
+}
+@media print {
.jp-Cell-inputWrapper,
.jp-Cell-outputWrapper {
display: block;