Commit 97250f54 authored by Florian Rhiem's avatar Florian Rhiem

Add Sphinx extension and limited Python 3 compatibility

parent 961ba7f4
......@@ -6,7 +6,10 @@ import os
import shutil
import subprocess
import tempfile
import urlparse
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
import sys
from io import BytesIO
from PIL import Image
......@@ -25,7 +28,7 @@ OUT_PNG_FILENAME = "_converted_image{i:04d}.png"
def is_url(url):
return urlparse.urlparse(url).scheme not in ("", "file")
return urlparse(url).scheme not in ("", "file")
def load_and_convert_image(
......
......@@ -142,7 +142,7 @@ def convert_image_to_html_base64(image_filepath):
if filetype == "svg":
filetype = "svg+xml"
with open(image_filepath.encode(sys.getfilesystemencoding()), "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return "data:image/{format};base64,".format(format=filetype) + encoded_string
......
from . import directives
def setup(app):
app.add_directive("embedded-image", directives.EmbeddedImage)
app.add_directive("embedded-figure", directives.EmbeddedFigure)
app.add_directive("jupyter-outbox", directives.ParsedLiteral)
app.add_directive('tikz', directives.Tikz)
app.add_directive("tikz-figure", directives.TikzFigure)
app.connect('builder-inited', lambda app: directives.set_output_mode(app.builder.format))
return {'version': '0.1'}
......@@ -56,7 +56,7 @@ setup(
name="docutils-extended",
version=version,
packages=find_packages(),
python_requires=">=2.7, <3",
python_requires=">=2.7",
install_requires=install_requires,
entry_points={
"console_scripts": [
......@@ -80,7 +80,7 @@ setup(
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2 :: Only",
"Programming Language :: Python :: 3",
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment