Skip to content

Fix SVG default thumbnail support#810

Merged
larsoner merged 1 commit intosphinx-gallery:masterfrom
jacobolofsson:fix-svg-thumbnails
Apr 14, 2021
Merged

Fix SVG default thumbnail support#810
larsoner merged 1 commit intosphinx-gallery:masterfrom
jacobolofsson:fix-svg-thumbnails

Conversation

@jacobolofsson
Copy link
Copy Markdown
Contributor

In gen_rst.save_thumbnail() the file extension is from file_conf is
always used, regardless of the value of 'default_thumb_file'. If
'default_thumb_file' is .svg (or .gif) it is still passed to pillow,
which does not handle them properly.

@jacobolofsson
Copy link
Copy Markdown
Contributor Author

Pytest is failing on test_embed_links_and_styles. It fails locally for me on current master also. I would be grateful to anyone a bit more experienced in this lib to help resolve

    def test_embed_links_and_styles(sphinx_app):
        """Test that links and styles are embedded properly in doc."""
        out_dir = sphinx_app.outdir
        src_dir = sphinx_app.srcdir
        examples_dir = op.join(out_dir, 'auto_examples')
        assert op.isdir(examples_dir)
        example_files = os.listdir(examples_dir)
        assert 'plot_numpy_matplotlib.html' in example_files
        example_file = op.join(examples_dir, 'plot_numpy_matplotlib.html')
        with codecs.open(example_file, 'r', 'utf-8') as fid:
            lines = fid.read()
        # ensure we've linked properly
>       assert '#module-matplotlib.colors' in lines
E       assert '#module-matplotlib.colors' in '\r\n<!DOCTYPE html>\r\n\r\n<html>\r\n  <head>\r\n    <meta charset="utf-8" />\r\n    <meta name="viewport" content="w...lib.rst.txt"\r\n          rel="nofollow">Page source</a>\r\n    </div>\r\n\r\n    \r\n\r\n    \r\n  </body>\r\n</html>'

@larsoner
Copy link
Copy Markdown
Contributor

I'll take a look in #811

In gen_rst.save_thumbnail() the file extension is from file_conf is
always used, regardless of the value of 'default_thumb_file'.  If
'default_thumb_file' is .svg (or .gif) it is still passed to pillow,
which does not handle them properly.
@jacobolofsson
Copy link
Copy Markdown
Contributor Author

Thanks @larsoner that seemed to do the trick

@larsoner
Copy link
Copy Markdown
Contributor

In principle it would be nice to have a test for this but I think it would be too much of a pain. In the meantime this seems reasonable to me and CIs are happy at least with the PNG case, thanks @jacobolofsson

@larsoner larsoner merged commit facffb2 into sphinx-gallery:master Apr 14, 2021
@larsoner larsoner added the bug label Apr 14, 2021
@jacobolofsson jacobolofsson mentioned this pull request Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants