././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1741372709.8430395 sphinxcontrib_svg2pdfconverter-1.3.0/0000775000175000017500000000000014762636446017424 5ustar00thomasthomas././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1673633696.0 sphinxcontrib_svg2pdfconverter-1.3.0/LICENSE.txt0000664000175000017500000000261214360317640021232 0ustar00thomasthomasIf not otherwise noted, the extensions in this package are licensed under the following license. Copyright (c) 2018-2023 by Missing Link Electronics, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1741372709.8430395 sphinxcontrib_svg2pdfconverter-1.3.0/PKG-INFO0000644000175000017500000000627514762636446020531 0ustar00thomasthomasMetadata-Version: 2.2 Name: sphinxcontrib-svg2pdfconverter Version: 1.3.0 Summary: Sphinx SVG to PDF converter extension Author-email: Stefan Wiehler License: BSD-2-Clause Project-URL: Homepage, https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter Project-URL: Download, https://pypi.org/project/sphinxcontrib-svg2pdfconverter Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Framework :: Sphinx :: Extension Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Documentation Classifier: Topic :: Utilities Requires-Python: >=3.6 Description-Content-Type: text/x-rst License-File: LICENSE.txt Requires-Dist: Sphinx>=1.6.3 Provides-Extra: cairosvg Requires-Dist: cairosvg>=1.0; extra == "cairosvg" ************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_, ``rsvg-convert`` from `libRSVG `_ or `CairoSVG `_ as progressively more lightweight alternatives are used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape, libRSVG and CairoSVG by adding ``sphinxcontrib.inkscapeconverter``, ``sphinxcontrib.rsvgconverter`` or ``sphinxcontrib.cairosvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. CairoSVG requires additional dependencies to be installed with: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter[CairoSVG] CairoSVG and its dependencies may require additional tools during the installation depending on the OS you are using; see the `CairoSVG documentation `_ for further details. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_format`` The value provided to the RSVG converter's ``--format`` argument. In more recent RSVG builds, the ``pdf1.5`` format will generate the fewest warnings with LaTeX backends. By default, this is ``pdf``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the empty list ``[]``. CairoSVG -------- No configuration is required. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726156183.0 sphinxcontrib_svg2pdfconverter-1.3.0/README.rst0000664000175000017500000000430114670606627021105 0ustar00thomasthomas************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_, ``rsvg-convert`` from `libRSVG `_ or `CairoSVG `_ as progressively more lightweight alternatives are used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape, libRSVG and CairoSVG by adding ``sphinxcontrib.inkscapeconverter``, ``sphinxcontrib.rsvgconverter`` or ``sphinxcontrib.cairosvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. CairoSVG requires additional dependencies to be installed with: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter[CairoSVG] CairoSVG and its dependencies may require additional tools during the installation depending on the OS you are using; see the `CairoSVG documentation `_ for further details. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_format`` The value provided to the RSVG converter's ``--format`` argument. In more recent RSVG builds, the ``pdf1.5`` format will generate the fewest warnings with LaTeX backends. By default, this is ``pdf``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the empty list ``[]``. CairoSVG -------- No configuration is required. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372453.0 sphinxcontrib_svg2pdfconverter-1.3.0/pyproject.toml0000664000175000017500000000204614762636045022335 0ustar00thomasthomas[build-system] requires = ["setuptools >=61.0.0", "wheel"] build-backend = "setuptools.build_meta" [project] name = "sphinxcontrib-svg2pdfconverter" version = "1.3.0" description = "Sphinx SVG to PDF converter extension" readme = "README.rst" license = {text = "BSD-2-Clause"} authors = [ {name = "Stefan Wiehler", email = "sphinx_contribute@missinglinkelectronics.com"}, ] classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Environment :: Web Environment", "Framework :: Sphinx :: Extension", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Documentation", "Topic :: Utilities", ] requires-python = ">=3.6" dependencies = [ "Sphinx>=1.6.3", ] [project.urls] Homepage = "https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter" Download = "https://pypi.org/project/sphinxcontrib-svg2pdfconverter" [project.optional-dependencies] CairoSVG = [ "cairosvg>=1.0", ] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1741372709.8430395 sphinxcontrib_svg2pdfconverter-1.3.0/setup.cfg0000664000175000017500000000004614762636446021245 0ustar00thomasthomas[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372425.0 sphinxcontrib_svg2pdfconverter-1.3.0/setup.py0000664000175000017500000000004114762636011021115 0ustar00thomasthomas__import__('setuptools').setup() ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1741372709.8420396 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib/0000775000175000017500000000000014762636446022316 5ustar00thomasthomas././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372425.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib/__init__.py0000664000175000017500000000072314762636011024415 0ustar00thomasthomas# -*- coding: utf-8 -*- """ sphinxcontrib ~~~~~~~~~~~~~ This package is a namespace package that contains all extensions distributed in the ``sphinx-contrib`` distribution. :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE.txt for details. """ try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: __path__ = __import__('pkgutil').extend_path(__path__, __name__) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1673633675.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib/cairosvgconverter.py0000664000175000017500000000405514360317613026423 0ustar00thomasthomas# -*- coding: utf-8 -*- """ sphinxcontrib.cairosvgconverter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Converts SVG images to PDF using CairoSVG in case the builder does not support SVG images natively (e.g. LaTeX). See . :copyright: Copyright 2018-2023 by Stefan Wiehler and Copyright 2020 by Marko Kohtala . :license: BSD, see LICENSE.txt for details. """ from sphinx.errors import ExtensionError from sphinx.locale import __ from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util import logging from urllib.error import URLError if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class CairoSVGConverter(ImageConverter): conversion_rules = [ ('image/svg+xml', 'application/pdf'), ] def is_available(self): # type: () -> bool """Confirms if CairoSVG package is available or not.""" try: import cairosvg # noqa: F401 return True except ImportError: logger.warning(__('CairoSVG package cannot be imported. ' 'Check if CairoSVG has been installed properly')) return False def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image from SVG to PDF via CairoSVG.""" import cairosvg try: cairosvg.svg2pdf(file_obj=open(_from, 'rb'), write_to=_to) except (OSError, URLError) as err: raise ExtensionError(__('CairoSVG converter failed with reason: ' '%s') % err.reason) return True def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_post_transform(CairoSVGConverter) return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1673633655.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib/inkscapeconverter.py0000664000175000017500000001007614360317567026413 0ustar00thomasthomas# -*- coding: utf-8 -*- """ sphinxcontrib.inkscapeconverter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Converts SVG images to PDF using Inkscape in case the builder does not support SVG images natively (e.g. LaTeX). :copyright: Copyright 2018-2023 by Stefan Wiehler . :license: BSD, see LICENSE.txt for details. """ import re import subprocess from sphinx.errors import ExtensionError from sphinx.locale import __ from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util import logging from errno import ENOENT, EPIPE, EINVAL if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class InkscapeConverter(ImageConverter): conversion_rules = [ ('image/svg+xml', 'application/pdf'), ] inkscape_version: str = "" def is_available(self): # type: () -> bool """Confirms if Inkscape is available or not.""" try: args = [self.config.inkscape_converter_bin, '--version'] logger.debug('Invoking %r ...', args) output = subprocess.check_output( args, stdin=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) match = re.search('Inkscape (.+)', output) if not match: logger.warning(__('Inkscape command %r returned invalid result: %s\n ' 'Check the inkscape_converter_bin setting'), self.config.inkscape_converter_bin, output) return False InkscapeConverter.inkscape_version = match.group(1) logger.debug('Inkscape version: %s', InkscapeConverter.inkscape_version) return True except subprocess.CalledProcessError: return False except (OSError, IOError): logger.warning(__('Inkscape command %r cannot be run. ' 'Check the inkscape_converter_bin setting'), self.config.inkscape_converter_bin) return False def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image from SVG to PDF via Inkscape.""" try: args = ([self.config.inkscape_converter_bin] + self.config.inkscape_converter_args) if InkscapeConverter.inkscape_version.startswith('1.'): args += ['--export-filename=' + _to, _from] else: args += ['--export-pdf=' + _to, _from] logger.debug('Invoking %r ...', args) p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError as err: if err.errno != ENOENT: # No such file or directory raise logger.warning(__('Inkscape command %r cannot be run. ' 'Check the inkscape_converter_bin setting'), self.config.inkscape_converter_bin) return False try: stdout, stderr = p.communicate() except (OSError, IOError) as err: if err.errno not in (EPIPE, EINVAL): raise stdout, stderr = p.stdout.read(), p.stderr.read() p.wait() if p.returncode != 0: raise ExtensionError(__('Inkscape exited with error:\n' '[stderr]\n%s\n[stdout]\n%s') % (stderr, stdout)) return True def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_post_transform(InkscapeConverter) app.add_config_value('inkscape_converter_bin', 'inkscape', 'env') app.add_config_value('inkscape_converter_args', ['--export-area-drawing'], 'env') return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741371058.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib/rsvgconverter.py0000664000175000017500000000647114762633262025602 0ustar00thomasthomas# -*- coding: utf-8 -*- """ sphinxcontrib.rsvgconverter ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Converts SVG images to PDF using libRSVG in case the builder does not support SVG images natively (e.g. LaTeX). :copyright: Copyright 2018-2023 by Stefan Wiehler . :license: BSD, see LICENSE.txt for details. """ import subprocess from sphinx.errors import ExtensionError from sphinx.locale import __ from sphinx.transforms.post_transforms.images import ImageConverter from sphinx.util import logging from errno import ENOENT, EPIPE, EINVAL if False: # For type annotation from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) class RSVGConverter(ImageConverter): conversion_rules = [ ('image/svg+xml', 'application/pdf'), ] def is_available(self): # type: () -> bool """Confirms if RSVG converter is available or not.""" try: args = [self.config.rsvg_converter_bin, '--version'] logger.debug('Invoking %r ...', args) ret = subprocess.call(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) if ret == 0: return True else: return False except (OSError, IOError): logger.warning(__('RSVG converter command %r cannot be run. ' 'Check the rsvg_converter_bin setting'), self.config.rsvg_converter_bin) return False def convert(self, _from, _to): # type: (unicode, unicode) -> bool """Converts the image from SVG to PDF via libRSVG.""" try: args = ([self.config.rsvg_converter_bin] + self.config.rsvg_converter_args + ['--format=' + self.config.rsvg_converter_format, '--output=' + str(_to), str(_from)]) logger.debug('Invoking %r ...', args) p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) except OSError as err: if err.errno != ENOENT: # No such file or directory raise logger.warning(__('RSVG converter command %r cannot be run. ' 'Check the rsvg_converter_bin setting'), self.config.rsvg_converter_bin) return False try: stdout, stderr = p.communicate() except (OSError, IOError) as err: if err.errno not in (EPIPE, EINVAL): raise stdout, stderr = p.stdout.read(), p.stderr.read() p.wait() if p.returncode != 0: raise ExtensionError(__('RSVG converter exited with error:\n' '[stderr]\n%s\n[stdout]\n%s') % (stderr, stdout)) return True def setup(app): # type: (Sphinx) -> Dict[unicode, Any] app.add_post_transform(RSVGConverter) app.add_config_value('rsvg_converter_bin', 'rsvg-convert', 'env') app.add_config_value('rsvg_converter_args', [], 'env') app.add_config_value('rsvg_converter_format', 'pdf', 'env') return { 'version': 'builtin', 'parallel_read_safe': True, 'parallel_write_safe': True, } ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1741372709.8430395 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/0000775000175000017500000000000014762636446027373 5ustar00thomasthomas././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372709.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/PKG-INFO0000644000175000017500000000627514762636445030477 0ustar00thomasthomasMetadata-Version: 2.2 Name: sphinxcontrib-svg2pdfconverter Version: 1.3.0 Summary: Sphinx SVG to PDF converter extension Author-email: Stefan Wiehler License: BSD-2-Clause Project-URL: Homepage, https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter Project-URL: Download, https://pypi.org/project/sphinxcontrib-svg2pdfconverter Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: Environment :: Web Environment Classifier: Framework :: Sphinx :: Extension Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Documentation Classifier: Topic :: Utilities Requires-Python: >=3.6 Description-Content-Type: text/x-rst License-File: LICENSE.txt Requires-Dist: Sphinx>=1.6.3 Provides-Extra: cairosvg Requires-Dist: cairosvg>=1.0; extra == "cairosvg" ************************************* Sphinx SVG to PDF Converter Extension ************************************* This extension converts SVG images to PDF in case the builder does not support SVG images natively (e.g. LaTeX). Internally, either `Inkscape `_, ``rsvg-convert`` from `libRSVG `_ or `CairoSVG `_ as progressively more lightweight alternatives are used to convert images. Installation ============ Just install via ``pip``: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter You can choose between Inkscape, libRSVG and CairoSVG by adding ``sphinxcontrib.inkscapeconverter``, ``sphinxcontrib.rsvgconverter`` or ``sphinxcontrib.cairosvgconverter`` to the ``extensions`` list in your ``conf.py``. Make sure to have either ``inkscape`` or the ``rsvg-convert`` command available in your systems ``PATH`` and, if necessary, adapt the ``inkscape_converter_bin`` or ``rsvg_converter_bin`` config value respectively. CairoSVG requires additional dependencies to be installed with: .. code-block:: console $ pip install sphinxcontrib-svg2pdfconverter[CairoSVG] CairoSVG and its dependencies may require additional tools during the installation depending on the OS you are using; see the `CairoSVG documentation `_ for further details. Configuration ============= Inkscape -------- ``inkscape_converter_bin`` Path to Inkscape binary. By default, this is ``inkscape``. ``inkscape_converter_args`` Additional command-line arguments for Inkscape, as a list. By default, this is ``['--export-area-drawing']``. RSVG ---- ``rsvg_converter_bin`` Path to RSVG converter binary. By default, this is ``rsvg-convert``. ``rsvg_converter_format`` The value provided to the RSVG converter's ``--format`` argument. In more recent RSVG builds, the ``pdf1.5`` format will generate the fewest warnings with LaTeX backends. By default, this is ``pdf``. ``rsvg_converter_args`` Additional command-line arguments for the RSVG converter, as a list. By default, this is the empty list ``[]``. CairoSVG -------- No configuration is required. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372709.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/SOURCES.txt0000664000175000017500000000067214762636445031263 0ustar00thomasthomasLICENSE.txt README.rst pyproject.toml setup.py sphinxcontrib/__init__.py sphinxcontrib/cairosvgconverter.py sphinxcontrib/inkscapeconverter.py sphinxcontrib/rsvgconverter.py sphinxcontrib_svg2pdfconverter.egg-info/PKG-INFO sphinxcontrib_svg2pdfconverter.egg-info/SOURCES.txt sphinxcontrib_svg2pdfconverter.egg-info/dependency_links.txt sphinxcontrib_svg2pdfconverter.egg-info/requires.txt sphinxcontrib_svg2pdfconverter.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372709.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/dependency_links.txt0000664000175000017500000000000114762636445033440 0ustar00thomasthomas ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372709.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/requires.txt0000664000175000017500000000005014762636445031765 0ustar00thomasthomasSphinx>=1.6.3 [CairoSVG] cairosvg>=1.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1741372709.0 sphinxcontrib_svg2pdfconverter-1.3.0/sphinxcontrib_svg2pdfconverter.egg-info/top_level.txt0000664000175000017500000000001614762636445032121 0ustar00thomasthomassphinxcontrib