Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doc-utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
doc-utils
doc-utils
Commits
16325f8c
Commit
16325f8c
authored
Aug 08, 2018
by
Ingo Meyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a wrongly named variable in the `EmbeddedImage` directive
parent
cc304090
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
docutils_extended/_version.py
docutils_extended/_version.py
+1
-1
docutils_extended/directives/embedded_image_directive.py
docutils_extended/directives/embedded_image_directive.py
+7
-7
No files found.
docutils_extended/_version.py
View file @
16325f8c
__version_info__
=
(
0
,
1
,
8
)
__version_info__
=
(
0
,
1
,
9
)
__version__
=
'.'
.
join
(
map
(
str
,
__version_info__
))
docutils_extended/directives/embedded_image_directive.py
View file @
16325f8c
...
...
@@ -15,15 +15,15 @@ def is_url(url):
return
urlparse
.
urlparse
(
url
).
scheme
not
in
(
""
,
"file"
)
def
convert_
png_to_pillow_image_and_html_base64
(
png
_filepath_or_url
):
if
is_url
(
png
_filepath_or_url
):
png_url
=
png
_filepath_or_url
response
=
requests
.
get
(
png
_url
)
def
convert_
image_to_pillow_image_and_html_base64
(
image
_filepath_or_url
):
if
is_url
(
image
_filepath_or_url
):
image_url
=
image
_filepath_or_url
response
=
requests
.
get
(
image
_url
)
response
.
raise_for_status
()
image_content
=
response
.
content
else
:
png_filepath
=
png
_filepath_or_url
with
open
(
png
_filepath
.
encode
(
sys
.
getfilesystemencoding
()),
"rb"
)
as
image_file
:
image_filepath
=
image
_filepath_or_url
with
open
(
image
_filepath
.
encode
(
sys
.
getfilesystemencoding
()),
"rb"
)
as
image_file
:
image_content
=
image_file
.
read
()
image
=
Image
.
open
(
BytesIO
(
image_content
))
encoded_string
=
"data:image/{format};base64,"
.
format
(
format
=
image
.
format
.
lower
())
+
base64
.
b64encode
(
image_content
)
...
...
@@ -56,7 +56,7 @@ class EmbeddedImage(Directive):
%
(
self
.
name
,
self
.
options
[
"align"
],
'", "'
.
join
(
self
.
align_values
))
)
messages
=
[]
image
,
encoded_string
=
convert_
png
_to_pillow_image_and_html_base64
(
image_filepath
)
image
,
encoded_string
=
convert_
image
_to_pillow_image_and_html_base64
(
image_filepath
)
reference
=
directives
.
uri
(
encoded_string
)
self
.
options
[
"uri"
]
=
reference
if
not
any
(
attr
in
self
.
options
for
attr
in
(
"height"
,
"width"
,
"scale"
)):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment