public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/, dev-python/nbconvert/files/
@ 2015-11-30  9:50 Justin Lecher
  0 siblings, 0 replies; 4+ messages in thread
From: Justin Lecher @ 2015-11-30  9:50 UTC (permalink / raw
  To: gentoo-commits

commit:     4cc5b3f16fc8724966b0105102eddd042dd5187b
Author:     Marius Brehler <marbre <AT> linux <DOT> sungazer <DOT> de>
AuthorDate: Mon Nov 30 09:40:15 2015 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Mon Nov 30 09:40:15 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4cc5b3f1

dev-python/nbconvert: Add missing patch

Package-Manager: portage-2.2.20.1

 .../nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch  | 16 ++++++++++++++++
 dev-python/nbconvert/nbconvert-4.1.0.ebuild              |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch b/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch
new file mode 100644
index 0000000..130a4af
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch
@@ -0,0 +1,16 @@
+nbconvert is not yet installed at time of doc generation.
+
+Patch by Marius Brehler
+--- docs/Makefile
++++ docs/Makefile
+@@ -61,8 +61,8 @@ source/config_options.rst:
+ 	@echo "Created docs for config options"
+ 
+ ipynb2rst:
+-	jupyter nbconvert --to rst source/customizing.ipynb --FilesWriter.build_directory=source
+-	jupyter nbconvert --to rst source/nbconvert_library.ipynb --FilesWriter.build_directory=source
++	../scripts/jupyter-nbconvert --to rst source/customizing.ipynb --FilesWriter.build_directory=source
++	../scripts/jupyter-nbconvert --to rst source/nbconvert_library.ipynb --FilesWriter.build_directory=source
+ 	@echo "Converted notebooks to rst"
+ 
+ dirhtml:

diff --git a/dev-python/nbconvert/nbconvert-4.1.0.ebuild b/dev-python/nbconvert/nbconvert-4.1.0.ebuild
index c6973b8..e57455a 100644
--- a/dev-python/nbconvert/nbconvert-4.1.0.ebuild
+++ b/dev-python/nbconvert/nbconvert-4.1.0.ebuild
@@ -20,7 +20,7 @@ KEYWORDS="~amd64 ~x86"
 IUSE="doc test"
 
 PATCHES=(
-	"${FILESDIR}"/${PN}-4.0.0-docs-Makefile.patch
+	"${FILESDIR}"/${P}-docs-Makefile.patch
 )
 
 RDEPEND="


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/, dev-python/nbconvert/files/
@ 2018-05-16 15:58 Andreas Sturmlechner
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Sturmlechner @ 2018-05-16 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     94f0cde59ff7d5981f62d34103dd18e641748728
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Wed May 16 13:39:31 2018 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed May 16 15:56:56 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=94f0cde5

dev-python/nbconvert: Drop old

Package-Manager: Portage-2.3.36, Repoman-2.3.9

 dev-python/nbconvert/Manifest                      |  3 -
 .../files/nbconvert-4.1.0-docs-Makefile.patch      | 16 -----
 dev-python/nbconvert/nbconvert-4.1.0.ebuild        | 77 ----------------------
 dev-python/nbconvert/nbconvert-4.2.0.ebuild        | 75 ---------------------
 dev-python/nbconvert/nbconvert-4.3.0.ebuild        | 73 --------------------
 5 files changed, 244 deletions(-)

diff --git a/dev-python/nbconvert/Manifest b/dev-python/nbconvert/Manifest
index 5b66c2833a7..2d40ec53192 100644
--- a/dev-python/nbconvert/Manifest
+++ b/dev-python/nbconvert/Manifest
@@ -1,4 +1 @@
-DIST nbconvert-4.1.0.tar.gz 263948 BLAKE2B fa0ade4e6b6c22bfea05c114211c1ddeba8a80e2e7b932c1fa5de6a15f908c019f9ccdfa10698ca3570231e03d988f72892d837acf340994fd94f3fce5e4b1c2 SHA512 9761cf8cdf206bd8f27c666d7b520cbd7d805353cf46b212b46ee6053b47ec6728a5926dfe59acef109c8770580c41d51aa5b943a27e72bccecc68a7d7b68bfb
-DIST nbconvert-4.2.0.tar.gz 428726 BLAKE2B f7d691d1d2fc6fcfa0e7d838cd44f5be60bae9e2015a92fea0c4af53e70ceb6d736f329da4ecf25ad82a8b39f15d4c22fef807f24f09d62d717d5ed5d5ac9c57 SHA512 441d32e5bd63cb7d0b9a70b814ec6ea647a04542601461cb8b008f4f9ab894f5729687093400703b222435100384378653fbbb38427431d9da62992ef778906a
-DIST nbconvert-4.3.0.tar.gz 377486 BLAKE2B ff8e09070d1c4dc0febc2c43712442406708461aa1ecef1c5a85c6821b6a34d1a3571c3e24d12a8403757350b29302ca19c16bd36514b191f63552c67948ce0c SHA512 ae5ca7c08dc052a20019309301d0d0d396498fc367614480c24192cc7fd059c31856d59594da7823463e14b769e4775d41c7942aa13d90ad7186aaa08ab4cdfc
 DIST nbconvert-5.2.1.tar.gz 510937 BLAKE2B aade38372775b032287f420ea4d335ad949a80afc0df63859db5a4f520bbaa22fcd17bf4318b05fa042fe94c2f65890aa2ed2365206abe8cdfb357817b056ac7 SHA512 c71c95d6c7bda4b55afad792d108d48c27857e060531dc8ec262673971c258ff9480821bd78ee5cbdbb19f107d5f8d19a49eac88819f20a09b450c26681335fa

diff --git a/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch b/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch
deleted file mode 100644
index 130a4afc06c..00000000000
--- a/dev-python/nbconvert/files/nbconvert-4.1.0-docs-Makefile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-nbconvert is not yet installed at time of doc generation.
-
-Patch by Marius Brehler
---- docs/Makefile
-+++ docs/Makefile
-@@ -61,8 +61,8 @@ source/config_options.rst:
- 	@echo "Created docs for config options"
- 
- ipynb2rst:
--	jupyter nbconvert --to rst source/customizing.ipynb --FilesWriter.build_directory=source
--	jupyter nbconvert --to rst source/nbconvert_library.ipynb --FilesWriter.build_directory=source
-+	../scripts/jupyter-nbconvert --to rst source/customizing.ipynb --FilesWriter.build_directory=source
-+	../scripts/jupyter-nbconvert --to rst source/nbconvert_library.ipynb --FilesWriter.build_directory=source
- 	@echo "Converted notebooks to rst"
- 
- dirhtml:

diff --git a/dev-python/nbconvert/nbconvert-4.1.0.ebuild b/dev-python/nbconvert/nbconvert-4.1.0.ebuild
deleted file mode 100644
index 3d32feec95e..00000000000
--- a/dev-python/nbconvert/nbconvert-4.1.0.ebuild
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=5
-
-PYTHON_COMPAT=( python2_7 python3_{4,5} )
-
-inherit distutils-r1
-
-MY_PN="nbconvert"
-
-DESCRIPTION="Converting Jupyter Notebooks"
-HOMEPAGE="http://jupyter.org"
-SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64 ~x86"
-IUSE="doc test"
-
-PATCHES=(
-	"${FILESDIR}"/${P}-docs-Makefile.patch
-)
-
-RDEPEND="
-	dev-python/jupyter_core[${PYTHON_USEDEP}]
-	dev-python/nbformat[${PYTHON_USEDEP}]
-	dev-python/mistune[${PYTHON_USEDEP}]
-	dev-python/jinja[${PYTHON_USEDEP}]
-	dev-python/pygments[${PYTHON_USEDEP}]
-	dev-python/traitlets[${PYTHON_USEDEP}]
-	"
-DEPEND="${RDEPEND}
-	doc? (
-		dev-python/ipython[${PYTHON_USEDEP}]
-		dev-python/jupyter_client[${PYTHON_USEDEP}]
-		dev-python/sphinx[${PYTHON_USEDEP}]
-		app-text/pandoc
-	)
-	test? (
-		dev-python/nose[${PYTHON_USEDEP}]
-		dev-python/coverage[${PYTHON_USEDEP}]
-		dev-python/ipykernel[${PYTHON_USEDEP}]
-	)
-	"
-
-python_prepare_all() {
-	# Prevent un-needed download during build
-	if use doc; then
-		sed -e "/^    'sphinx.ext.intersphinx',/d" -i docs/source/conf.py || die
-	fi
-
-	distutils-r1_python_prepare_all
-}
-
-python_compile_all() {
-	use doc && emake -C docs html
-}
-
-python_test() {
-	distutils_install_for_testing
-	cd "${TEST_DIR}"/lib || die
-	nosetests --with-coverage --cover-package=nbconvert nbconvert || die
-}
-
-python_install_all() {
-	use doc && HTML_DOCS=( docs/build/html/. )
-	distutils-r1_python_install_all
-}
-
-pkg_postinst() {
-	if ! has_version app-text/pandoc ; then
-		einfo "Pandoc is required for converting to formats other than Python,"
-		einfo "HTML, and Markdown. If you need this functionality, install"
-		einfo "app-text/pandoc."
-	fi
-}

diff --git a/dev-python/nbconvert/nbconvert-4.2.0.ebuild b/dev-python/nbconvert/nbconvert-4.2.0.ebuild
deleted file mode 100644
index 63fcc4d0011..00000000000
--- a/dev-python/nbconvert/nbconvert-4.2.0.ebuild
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 1999-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-PYTHON_COMPAT=( python2_7 python3_{4,5} )
-
-inherit distutils-r1
-
-DESCRIPTION="Converting Jupyter Notebooks"
-HOMEPAGE="http://jupyter.org"
-SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64 ~x86"
-IUSE="doc test"
-
-RDEPEND="
-	dev-python/jupyter_core[${PYTHON_USEDEP}]
-	dev-python/nbformat[${PYTHON_USEDEP}]
-	dev-python/mistune[${PYTHON_USEDEP}]
-	dev-python/jinja[${PYTHON_USEDEP}]
-	dev-python/pygments[${PYTHON_USEDEP}]
-	dev-python/traitlets[${PYTHON_USEDEP}]
-	dev-python/entrypoints[${PYTHON_USEDEP}]
-	"
-DEPEND="${RDEPEND}
-	doc? (
-		dev-python/ipython[${PYTHON_USEDEP}]
-		dev-python/jupyter_client[${PYTHON_USEDEP}]
-		dev-python/sphinx[${PYTHON_USEDEP}]
-		dev-python/nbsphinx[${PYTHON_USEDEP}]
-		app-text/pandoc
-	)
-	test? (
-		dev-python/pytest[${PYTHON_USEDEP}]
-		dev-python/pytest-cov[${PYTHON_USEDEP}]
-		dev-python/nose[${PYTHON_USEDEP}]
-		dev-python/ipykernel[${PYTHON_USEDEP}]
-		dev-python/testpath[${PYTHON_USEDEP}]
-	)
-	"
-
-python_prepare_all() {
-	# Prevent un-needed download during build
-	if use doc; then
-		sed -e "/^    'sphinx.ext.intersphinx',/d" -i docs/source/conf.py || die
-	fi
-
-	distutils-r1_python_prepare_all
-}
-
-python_compile_all() {
-	use doc && emake -C docs html
-}
-
-python_test() {
-	distutils_install_for_testing
-	cd "${TEST_DIR}"/lib || die
-	py.test --cov nbconvert -v --pyargs nbconvert || die
-}
-
-python_install_all() {
-	use doc && HTML_DOCS=( docs/build/html/. )
-	distutils-r1_python_install_all
-}
-
-pkg_postinst() {
-	if ! has_version app-text/pandoc ; then
-		einfo "Pandoc is required for converting to formats other than Python,"
-		einfo "HTML, and Markdown. If you need this functionality, install"
-		einfo "app-text/pandoc."
-	fi
-}

diff --git a/dev-python/nbconvert/nbconvert-4.3.0.ebuild b/dev-python/nbconvert/nbconvert-4.3.0.ebuild
deleted file mode 100644
index 15db15fac52..00000000000
--- a/dev-python/nbconvert/nbconvert-4.3.0.ebuild
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
-
-inherit distutils-r1
-
-DESCRIPTION="Converting Jupyter Notebooks"
-HOMEPAGE="http://jupyter.org"
-SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64 ~arm64 ~x86"
-IUSE="doc test"
-
-RDEPEND="
-	dev-python/jupyter_core[${PYTHON_USEDEP}]
-	dev-python/nbformat[${PYTHON_USEDEP}]
-	dev-python/mistune[${PYTHON_USEDEP}]
-	dev-python/jinja[${PYTHON_USEDEP}]
-	dev-python/pygments[${PYTHON_USEDEP}]
-	dev-python/traitlets[${PYTHON_USEDEP}]
-	dev-python/entrypoints[${PYTHON_USEDEP}]
-	"
-DEPEND="${RDEPEND}
-	doc? (
-		dev-python/ipython[${PYTHON_USEDEP}]
-		dev-python/jupyter_client[${PYTHON_USEDEP}]
-		dev-python/sphinx[${PYTHON_USEDEP}]
-		dev-python/nbsphinx[${PYTHON_USEDEP}]
-		app-text/pandoc
-	)
-	test? (
-		dev-python/pytest[${PYTHON_USEDEP}]
-		dev-python/pytest-cov[${PYTHON_USEDEP}]
-		dev-python/nose[${PYTHON_USEDEP}]
-		dev-python/ipykernel[${PYTHON_USEDEP}]
-		dev-python/testpath[${PYTHON_USEDEP}]
-	)
-	"
-
-python_prepare_all() {
-	# Prevent un-needed download during build
-	if use doc; then
-		sed -e "/^    'sphinx.ext.intersphinx',/d" -i docs/source/conf.py || die
-	fi
-
-	distutils-r1_python_prepare_all
-}
-
-python_compile_all() {
-	if use doc; then
-		emake -C docs html
-		HTML_DOCS=( docs/build/html/. )
-	fi
-}
-
-python_test() {
-	distutils_install_for_testing
-	cd "${TEST_DIR}"/lib || die
-	py.test --cov nbconvert -v --pyargs nbconvert || die
-}
-
-pkg_postinst() {
-	if ! has_version app-text/pandoc ; then
-		einfo "Pandoc is required for converting to formats other than Python,"
-		einfo "HTML, and Markdown. If you need this functionality, install"
-		einfo "app-text/pandoc."
-	fi
-}


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/, dev-python/nbconvert/files/
@ 2020-06-10  7:32 Michał Górny
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2020-06-10  7:32 UTC (permalink / raw
  To: gentoo-commits

commit:     b071e8808e703ed0cb4354452b0b5d024da5967c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  9 18:05:20 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 10 07:31:46 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b071e880

dev-python/nbconvert: Port to py3.9

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../nbconvert/files/nbconvert-5.6.1-py39.patch     | 27 ++++++++++++++++++++++
 dev-python/nbconvert/nbconvert-5.6.1.ebuild        |  3 ++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch b/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch
new file mode 100644
index 00000000000..822c32753f8
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-5.6.1-py39.patch
@@ -0,0 +1,27 @@
+diff --git a/nbconvert/filters/strings.py b/nbconvert/filters/strings.py
+index 2673d661..9ae82a13 100755
+--- a/nbconvert/filters/strings.py
++++ b/nbconvert/filters/strings.py
+@@ -19,8 +19,8 @@ except ImportError:
+     from urllib2 import quote  # Py 2
+ 
+ # defusedxml does safe(r) parsing of untrusted XML data
+-from defusedxml import cElementTree as ElementTree
+-from xml.etree.cElementTree import Element
++from defusedxml import ElementTree
++from xml.etree.ElementTree import Element
+ 
+ from ipython_genutils import py3compat
+ 
+diff --git a/nbconvert/preprocessors/svg2pdf.py b/nbconvert/preprocessors/svg2pdf.py
+index aff14d9f..b689b1bc 100644
+--- a/nbconvert/preprocessors/svg2pdf.py
++++ b/nbconvert/preprocessors/svg2pdf.py
+@@ -105,6 +105,6 @@ class SVG2PDFPreprocessor(ConvertFiguresPreprocessor):
+             if os.path.isfile(output_filename):
+                 with open(output_filename, 'rb') as f:
+                     # PDF is a nb supported binary, data type, so base64 encode.
+-                    return base64.encodestring(f.read())
++                    return base64.encodebytes(f.read())
+             else:
+                 raise TypeError("Inkscape svg to pdf conversion failed")

diff --git a/dev-python/nbconvert/nbconvert-5.6.1.ebuild b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
index 0a81b48e8e2..594d35db111 100644
--- a/dev-python/nbconvert/nbconvert-5.6.1.ebuild
+++ b/dev-python/nbconvert/nbconvert-5.6.1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( python3_{6,7} )
+PYTHON_COMPAT=( python3_{6..9} )
 
 inherit distutils-r1
 
@@ -44,6 +44,7 @@ distutils_enable_tests pytest
 
 PATCHES=(
 	"${FILESDIR}"/${P}-inkscape-1.patch
+	"${FILESDIR}"/${P}-py39.patch
 )
 
 src_prepare() {


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/, dev-python/nbconvert/files/
@ 2022-05-27  6:10 Michał Górny
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2022-05-27  6:10 UTC (permalink / raw
  To: gentoo-commits

commit:     f66a4fc204598c2abfe388b680694e3ff0d2dbbb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri May 27 04:54:04 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri May 27 06:10:27 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f66a4fc2

dev-python/nbconvert: Support mistune-2

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/nbconvert-6.5.0-mistune-2.patch          | 339 +++++++++++++++++++++
 dev-python/nbconvert/nbconvert-6.5.0-r1.ebuild     |  82 +++++
 2 files changed, 421 insertions(+)

diff --git a/dev-python/nbconvert/files/nbconvert-6.5.0-mistune-2.patch b/dev-python/nbconvert/files/nbconvert-6.5.0-mistune-2.patch
new file mode 100644
index 000000000000..4a3f4731b32d
--- /dev/null
+++ b/dev-python/nbconvert/files/nbconvert-6.5.0-mistune-2.patch
@@ -0,0 +1,339 @@
+From 6e5ba41803cc8c3192f001b3ede9b74454220bda Mon Sep 17 00:00:00 2001
+From: Tiago de Paula <tiagodepalves@gmail.com>
+Date: Mon, 9 May 2022 09:39:31 -0300
+Subject: [PATCH] Update to Mistune 2.0.2 (#1764)
+
+Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
+---
+ nbconvert/filters/markdown_mistune.py | 212 ++++++++++++++------------
+ setup.py                              |   2 +-
+ 2 files changed, 119 insertions(+), 95 deletions(-)
+
+diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py
+index 382a5388..636e1e8c 100644
+--- a/nbconvert/filters/markdown_mistune.py
++++ b/nbconvert/filters/markdown_mistune.py
+@@ -21,7 +21,7 @@ except ImportError:
+     from cgi import escape as html_escape
+ 
+ import bs4
+-import mistune
++from mistune import BlockParser, HTMLRenderer, InlineParser, Markdown
+ from pygments import highlight
+ from pygments.formatters import HtmlFormatter
+ from pygments.lexers import get_lexer_by_name
+@@ -34,158 +34,183 @@ 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
+-    MathBlockLexer.
++class MathBlockParser(BlockParser):
++    """This acts as a pass-through to the MathInlineParser. It is needed in
++    order to avoid other block level rules splitting math sections apart.
+     """
+ 
+-    multi_math_str = "|".join(
+-        [r"^\$\$.*?\$\$", r"^\\\\\[.*?\\\\\]", r"^\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}"]
++    MULTILINE_MATH = re.compile(
++        r"(?<!\\)[$]{2}.*?(?<!\\)[$]{2}|"
++        r"\\\\\[.*?\\\\\]|"
++        r"\\begin\{([a-z]*\*?)\}.*?\\end\{\1\}",
++        re.DOTALL,
+     )
+-    multiline_math = re.compile(multi_math_str, re.DOTALL)
+ 
++    RULE_NAMES = ("multiline_math",) + BlockParser.RULE_NAMES
+ 
+-class MathBlockLexer(mistune.BlockLexer):
+-    """This acts as a pass-through to the MathInlineLexer. It is needed in
+-    order to avoid other block level rules splitting math sections apart.
+-    """
++    # Regex for header that doesn't require space after '#'
++    AXT_HEADING = re.compile(r" {0,3}(#{1,6})(?!#+)\s*([^\n]*?)$")
+ 
+-    default_rules = ["multiline_math"] + mistune.BlockLexer.default_rules
++    def parse_multiline_math(self, m, state):
++        """Pass token through mutiline math."""
++        return {"type": "multiline_math", "text": m.group(0)}
+ 
+-    def __init__(self, rules=None, **kwargs):
+-        if rules is None:
+-            rules = MathBlockGrammar()
+-        super().__init__(rules, **kwargs)
+ 
+-    def parse_multiline_math(self, m):
+-        """Add token to pass through mutiline math."""
+-        self.tokens.append({"type": "multiline_math", "text": m.group(0)})
++def _dotall(pattern):
++    """Make the '.' special character match any character inside the pattern, including a newline.
+ 
+-
+-class MathInlineGrammar(mistune.InlineGrammar):
+-    """This defines different ways of declaring math objects that should be
+-    passed through to mathjax unaffected. These are used by the MathInlineLexer.
++    This is implemented with the inline flag `(?s:...)` and is equivalent to using `re.DOTALL` when
++    it is the only pattern used. It is necessary since `mistune>=2.0.0`, where the pattern is passed
++    to the undocumented `re.Scanner`.
+     """
+-
+-    inline_math = re.compile(r"^\$(.+?)\$|^\\\\\((.+?)\\\\\)", re.DOTALL)
+-    block_math = re.compile(r"^\$\$(.*?)\$\$|^\\\\\[(.*?)\\\\\]", re.DOTALL)
+-    latex_environment = re.compile(r"^\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}", re.DOTALL)
+-    text = re.compile(r"^[\s\S]+?(?=[\\<!\[_*`~$]|https?://| {2,}\n|$)")
++    return f"(?s:{pattern})"
+ 
+ 
+-class MathInlineLexer(mistune.InlineLexer):
+-    r"""This interprets the content of LaTeX style math objects using the rules
+-    defined by the MathInlineGrammar.
++class MathInlineParser(InlineParser):
++    r"""This interprets the content of LaTeX style math objects.
+ 
+     In particular this grabs ``$$...$$``, ``\\[...\\]``, ``\\(...\\)``, ``$...$``,
+     and ``\begin{foo}...\end{foo}`` styles for declaring mathematics. It strips
+     delimiters from all these varieties, and extracts the type of environment
+     in the last case (``foo`` in this example).
+     """
+-    default_rules = [
+-        "block_math",
+-        "inline_math",
++    BLOCK_MATH_TEX = _dotall(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$")
++    BLOCK_MATH_LATEX = _dotall(r"(?<!\\)\\\\\[(.*?)(?<!\\)\\\\\]")
++    INLINE_MATH_TEX = _dotall(r"(?<![$\\])\$(.+?)(?<![$\\])\$")
++    INLINE_MATH_LATEX = _dotall(r"(?<!\\)\\\\\((.*?)(?<!\\)\\\\\)")
++    LATEX_ENVIRONMENT = _dotall(r"\\begin\{([a-z]*\*?)\}(.*?)\\end\{\1\}")
++
++    # The order is important here
++    RULE_NAMES = (
++        "block_math_tex",
++        "block_math_latex",
++        "inline_math_tex",
++        "inline_math_latex",
+         "latex_environment",
+-    ] + mistune.InlineLexer.default_rules
+-
+-    def __init__(self, renderer, rules=None, **kwargs):
+-        if rules is None:
+-            rules = MathInlineGrammar()
+-        super().__init__(renderer, rules, **kwargs)
+-
+-    def output_inline_math(self, m):
+-        return self.renderer.inline_math(m.group(1) or m.group(2))
+-
+-    def output_block_math(self, m):
+-        return self.renderer.block_math(m.group(1) or m.group(2) or "")
+-
+-    def output_latex_environment(self, m):
+-        return self.renderer.latex_environment(m.group(1), m.group(2))
+-
+-
+-class MarkdownWithMath(mistune.Markdown):
+-    def __init__(self, renderer, **kwargs):
+-        if "inline" not in kwargs:
+-            kwargs["inline"] = MathInlineLexer
+-        if "block" not in kwargs:
+-            kwargs["block"] = MathBlockLexer
+-        super().__init__(renderer, **kwargs)
+-
+-    def output_multiline_math(self):
+-        return self.inline(self.token["text"])
+-
+-
+-class IPythonRenderer(mistune.Renderer):
+-    def block_code(self, code, lang):
+-        if lang:
++    ) + InlineParser.RULE_NAMES
++
++    def parse_block_math_tex(self, m, state):
++        # sometimes the Scanner keeps the final '$$', so we use the
++        # full matched string and remove the math markers
++        text = m.group(0)[2:-2]
++        return "block_math", text
++
++    def parse_block_math_latex(self, m, state):
++        text = m.group(1)
++        return "block_math", text
++
++    def parse_inline_math_tex(self, m, state):
++        text = m.group(1)
++        return "inline_math", text
++
++    def parse_inline_math_latex(self, m, state):
++        text = m.group(1)
++        return "inline_math", text
++
++    def parse_latex_environment(self, m, state):
++        name, text = m.group(1), m.group(2)
++        return "latex_environment", name, text
++
++
++class MarkdownWithMath(Markdown):
++    def __init__(self, renderer, block=None, inline=None, plugins=None):
++        if block is None:
++            block = MathBlockParser()
++        if inline is None:
++            inline = MathInlineParser(renderer, hard_wrap=False)
++        super().__init__(renderer, block, inline, plugins)
++
++    def render(self, s):
++        """Compatibility method with `mistune==0.8.4`."""
++        return self.parse(s)
++
++
++class IPythonRenderer(HTMLRenderer):
++    def __init__(
++        self,
++        escape=True,
++        allow_harmful_protocols=True,
++        embed_images=False,
++        exclude_anchor_links=False,
++        anchor_link_text="¶",
++        path="",
++        attachments=None,
++    ):
++        super().__init__(escape, allow_harmful_protocols)
++        self.embed_images = embed_images
++        self.exclude_anchor_links = exclude_anchor_links
++        self.anchor_link_text = anchor_link_text
++        self.path = path
++        if attachments is not None:
++            self.attachments = attachments
++        else:
++            self.attachments = {}
++
++    def block_code(self, code, info=None):
++        if info:
+             try:
++                lang = info.strip().split(None, 1)[0]
+                 lexer = get_lexer_by_name(lang, stripall=True)
+             except ClassNotFound:
+                 code = lang + "\n" + code
+                 lang = None
+ 
+         if not lang:
+-            return "\n<pre><code>%s</code></pre>\n" % mistune.escape(code)
++            return super().block_code(code)
+ 
+         formatter = HtmlFormatter()
+         return highlight(code, lexer, formatter)
+ 
+     def block_html(self, html):
+-        embed_images = self.options.get("embed_images", False)
+-
+-        if embed_images:
++        if self.embed_images:
+             html = self._html_embed_images(html)
+ 
+         return super().block_html(html)
+ 
+     def inline_html(self, html):
+-        embed_images = self.options.get("embed_images", False)
+-
+-        if embed_images:
++        if self.embed_images:
+             html = self._html_embed_images(html)
+ 
+         return super().inline_html(html)
+ 
+-    def header(self, text, level, raw=None):
+-        html = super().header(text, level, raw=raw)
+-        if self.options.get("exclude_anchor_links"):
++    def heading(self, text, level):
++        html = super().heading(text, level)
++        if self.exclude_anchor_links:
+             return html
+-        anchor_link_text = self.options.get("anchor_link_text", "¶")
+-        return add_anchor(html, anchor_link_text=anchor_link_text)
++        return add_anchor(html, anchor_link_text=self.anchor_link_text)
+ 
+     def escape_html(self, text):
+         return html_escape(text)
+ 
++    def multiline_math(self, text):
++        return text
++
+     def block_math(self, text):
+-        return "$$%s$$" % self.escape_html(text)
++        return f"$${self.escape_html(text)}$$"
+ 
+     def latex_environment(self, name, text):
+-        name = self.escape_html(name)
+-        text = self.escape_html(text)
+-        return rf"\begin{{{name}}}{text}\end{{{name}}}"
++        name, text = self.escape_html(name), self.escape_html(text)
++        return f"\\begin{{{name}}}{text}\\end{{{name}}}"
+ 
+     def inline_math(self, text):
+-        return "$%s$" % self.escape_html(text)
++        return f"${self.escape_html(text)}$"
+ 
+-    def image(self, src, title, text):
++    def image(self, src, text, title):
+         """Rendering a image with title and text.
+ 
+         :param src: source link of the image.
+-        :param title: title text of the image.
+         :param text: alt text of the image.
++        :param title: title text of the image.
+         """
+-        attachments = self.options.get("attachments", {})
+         attachment_prefix = "attachment:"
+-        embed_images = self.options.get("embed_images", False)
+ 
+         if src.startswith(attachment_prefix):
+             name = src[len(attachment_prefix) :]
+ 
+-            if name not in attachments:
++            if name not in self.attachments:
+                 raise InvalidNotebook(f"missing attachment: {name}")
+ 
+-            attachment = attachments[name]
++            attachment = self.attachments[name]
+             # we choose vector over raster, and lossless over lossy
+             preferred_mime_types = ["image/svg+xml", "image/png", "image/jpeg"]
+             for preferred_mime_type in preferred_mime_types:
+@@ -197,13 +222,13 @@ class IPythonRenderer(mistune.Renderer):
+             data = attachment[mime_type]
+             src = "data:" + mime_type + ";base64," + data
+ 
+-        elif embed_images:
++        elif self.embed_images:
+             base64_url = self._src_to_base64(src)
+ 
+             if base64_url is not None:
+                 src = base64_url
+ 
+-        return super().image(src, title, text)
++        return super().image(src, text, title)
+ 
+     def _src_to_base64(self, src):
+         """Turn the source file into a base64 url.
+@@ -211,8 +236,7 @@ class IPythonRenderer(mistune.Renderer):
+         :param src: source link of the file.
+         :return: the base64 url or None if the file was not found.
+         """
+-        path = self.options.get("path", "")
+-        src_path = os.path.join(path, src)
++        src_path = os.path.join(self.path, src)
+ 
+         if not os.path.exists(src_path):
+             return None
+diff --git a/setup.py b/setup.py
+index 7220a875..2dfa2534 100644
+--- a/setup.py
++++ b/setup.py
+@@ -245,7 +245,7 @@ setup_args["install_requires"] = [
+     "jupyter_core>=4.7",
+     "jupyterlab_pygments",
+     "MarkupSafe>=2.0",
+-    "mistune>=0.8.1,<2",
++    "mistune>=2.0.2",
+     "nbclient>=0.5.0",
+     "nbformat>=5.1",
+     "packaging",
+-- 
+2.35.1
+

diff --git a/dev-python/nbconvert/nbconvert-6.5.0-r1.ebuild b/dev-python/nbconvert/nbconvert-6.5.0-r1.ebuild
new file mode 100644
index 000000000000..39c667a2c576
--- /dev/null
+++ b/dev-python/nbconvert/nbconvert-6.5.0-r1.ebuild
@@ -0,0 +1,82 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{8..10} )
+
+inherit distutils-r1
+
+DESCRIPTION="Converting Jupyter Notebooks"
+HOMEPAGE="
+	https://nbconvert.readthedocs.io/
+	https://github.com/jupyter/nbconvert/
+	https://pypi.org/project/nbconvert/
+"
+SRC_URI="
+	mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz
+"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
+
+RDEPEND="
+	dev-python/beautifulsoup4[${PYTHON_USEDEP}]
+	dev-python/bleach[${PYTHON_USEDEP}]
+	dev-python/defusedxml[${PYTHON_USEDEP}]
+	>=dev-python/entrypoints-0.2.2[${PYTHON_USEDEP}]
+	dev-python/jinja[${PYTHON_USEDEP}]
+	dev-python/jupyter_core[${PYTHON_USEDEP}]
+	dev-python/jupyterlab_pygments[${PYTHON_USEDEP}]
+	>=dev-python/markupsafe-2.0[${PYTHON_USEDEP}]
+	>=dev-python/mistune-2.0.2[${PYTHON_USEDEP}]
+	dev-python/nbclient[${PYTHON_USEDEP}]
+	dev-python/nbformat[${PYTHON_USEDEP}]
+	>=dev-python/pandocfilters-1.4.1[${PYTHON_USEDEP}]
+	dev-python/pygments[${PYTHON_USEDEP}]
+	>=dev-python/traitlets-5.1.1[${PYTHON_USEDEP}]
+	dev-python/testpath[${PYTHON_USEDEP}]
+	www-servers/tornado[${PYTHON_USEDEP}]
+"
+BDEPEND="
+	test? (
+		dev-python/pebble[${PYTHON_USEDEP}]
+		dev-python/ipykernel[${PYTHON_USEDEP}]
+		dev-python/ipywidgets[${PYTHON_USEDEP}]
+		>=dev-python/jupyter_client-4.2[${PYTHON_USEDEP}]
+	)
+"
+
+distutils_enable_tests pytest
+
+PATCHES=(
+	"${FILESDIR}"/${P}-mistune-2.patch
+)
+
+src_test() {
+	mkdir -p "${HOME}/.local" || die
+	cp -r share "${HOME}/.local/" || die
+	distutils-r1_src_test
+}
+
+python_test() {
+	local EPYTEST_DESELECT=(
+		# Missing pyppeteer for now
+		# TODO: Doesn't skip?
+		nbconvert/exporters/tests/test_webpdf.py
+		# Needs pyppeteer too
+		'nbconvert/tests/test_nbconvertapp.py::TestNbConvertApp::test_webpdf_with_chromium'
+	)
+
+	epytest --pyargs nbconvert
+}
+
+pkg_postinst() {
+	if ! has_version app-text/pandoc ; then
+		einfo "Pandoc is required for converting to formats other than Python,"
+		einfo "HTML, and Markdown. If you need this functionality, install"
+		einfo "app-text/pandoc."
+	fi
+}


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-27  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-30  9:50 [gentoo-commits] repo/gentoo:master commit in: dev-python/nbconvert/, dev-python/nbconvert/files/ Justin Lecher
  -- strict thread matches above, loose matches on Subject: below --
2018-05-16 15:58 Andreas Sturmlechner
2020-06-10  7:32 Michał Górny
2022-05-27  6:10 Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox