Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def replfunc(self, match):
return img

def from_notebook_node(self, nb, resources=None, **kw):
output, resources = super(EmbedHTMLExporter, self).from_notebook_node(nb, resources)
output, resources = super(
EmbedHTMLExporter, self).from_notebook_node(nb, resources)

regex = re.compile('<img\s+src="(\S+)"\s*(\S*)\s*')

Expand Down
7 changes: 5 additions & 2 deletions tests/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
import io
import os


def path_in_data(rel_path):
"""Return an absolute path from a relative path in tests/data."""
return os.path.join(os.path.dirname(__file__), 'data', rel_path)


class TestNbConvertExporters(TestsBase):

def test_embedhtml(self):
"""Test exporter for embedding images into HTML"""
with self.create_temp_cwd():
nb = v4.new_notebook(cells=[
v4.new_code_cell(source="a = 'world'"),
v4.new_markdown_cell(source="![testimage]({})".format(path_in_data('icon.png'))),
v4.new_markdown_cell(
source="![testimage]({})".format(path_in_data('icon.png'))
),
])
with io.open('notebook2.ipynb', 'w', encoding='utf-8') as f:
write(nb, f, 4)
Expand Down Expand Up @@ -47,4 +51,3 @@ def test_htmltoc2(self):
self.nbconvert('--to html_toc'
' "notebook2"')
assert os.path.isfile('notebook2.html')