Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working with <img> tags in nbsphinx #284

Closed
phaustin opened this issue Feb 12, 2019 · 11 comments
Closed

working with <img> tags in nbsphinx #284

phaustin opened this issue Feb 12, 2019 · 11 comments

Comments

@phaustin
Copy link

phaustin commented Feb 12, 2019

(all figures below were created from https://github.com/phaustin/nbsphinx_issue/tree/issue)

Since jupyter notebooks ignore attributes like width, height for markdown images, at the moment I'm
producing two versions of each notebook: one for jupyter ipynb files with <img> tags
and one for html nbsphinx conversion with ![altfig]() markdown tags.

Is there a way to get nbsphinx to handle img tags the way that nbconvert does?

@mgeier
Copy link
Member

mgeier commented Feb 18, 2019

What does nbconvert do when you convert your notebook to LaTeX/PDF?

Both nbconvert and nbsphinx use pandoc to parse the Markdown text, but I guess the difference is that nbconvert converts directly to HTML (or LaTeX), while nbsphinx converts to RST first.

There may be a way to force pandoc to keep the original <img> tag, but it would most likely not work for LaTeX output.

See also #52.

@phaustin
Copy link
Author

for future googlers -- this is the translation code I'm currently using to go back and forth between jupyter markdown and rst scaled images:

jupytext#305

@mluerig
Copy link

mluerig commented Mar 23, 2020

similar issue here - are you planning on integrating support for images as html elements soon?

@phaustin
Copy link
Author

This should be possible soon using myst_nb. This is very close to being a drop-in replacement for nbsphinx, although stil alpha. (e.g. see /executablebooks/MyST-NB#98)

@mluerig
Copy link

mluerig commented Mar 23, 2020

ok. I tried to understand your workaround (#284 (comment)) , but I wasn't sure where that gist goes - could you elaborate?

@phaustin
Copy link
Author

I was doing a separate step where I post-processed the notebooks and replaced the img tags with the corresponding markdown. That proved too cumbersome though, so I just started making a separate media folder with resized images. My current approach is to keep the img tags and use chrome pdf print instead of latex to produce pdf: see https://github.com/eoas-ubc/paged_trio

@mluerig
Copy link

mluerig commented Mar 23, 2020

ok thanks. I'll keep an eye out for MyST-NB

@mgeier
Copy link
Member

mgeier commented Mar 24, 2020

@mluerig In case this is addressed to me:

are you planning on integrating support for images as html elements soon?

No, I'm not planning to work on this anytime soon.
But I'm open for contributions!

@mluerig
Copy link

mluerig commented Mar 25, 2020

I got it to work by just using markdown for images inside my html div structure to scale, center and what not.

if I have the time at some point I'll get back to you

This was referenced Apr 17, 2020
@mgeier
Copy link
Member

mgeier commented Apr 18, 2020

Does #438 solve this issue?

@mgeier
Copy link
Member

mgeier commented May 11, 2020

I think this is solved with the latest nbsphinx release (0.7.0).

Please leave a comment if something is still missing!

@mgeier mgeier closed this as completed May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants