Comments (13)
No we won't go back to '<img src' since it doesn't display properly normal images with good resolution (examples: screenshots in the index of nbdev.fast.ai). We can add a hack for embedded images instead.
from nbdev.
One way to remove the errors is to add a return right before the os.makedirs()
line, (line 142):
if (src.startswith('http://') or src.startswith('https://')): return
Doing this solved my errors with external image URLs. (EDIT: see below, all this did was strip out the images though.)
Now...embedded objects (e.g. plots from plot.ly) are also being treated as they were files too. These extremely long strings then produce "filename too long" errors. Ideally, I'd imagine one would want to simply leave these things alone and 'pass them through', since they are already HTML.
from nbdev.
Ok, fixed the embedded object problem too:
if (src.startswith('http://') or src.startswith('https://') or src.startswith('data:image/')): return
...So now the build will complete without errors, and the plot.ly interactive plots work in the generated .html file, BUT...
but actually the external images links aren't present in the final html file!
So, my 'fix' return statement only seems to strip out the external images entirely.
from nbdev.
I think there were a few more things to add, but I added tests and all seems to pass now.
from nbdev.
Oh great! That fixes the external image problem. Thanks!
Now, could you also add a
if src.startswith('data:image/'): return
...to the line immediately before the os.makedirs()
line in copy_images()
?
Doing this will allow imbedded object-images such as interactive plots from plot.ly to work perfectly. :-)
from nbdev.
I added that. Can you make one last test on your side before we make a release?
from nbdev.
Thanks. Gladly. Um...I will need to read up on your methodologies for contributing tests the way you like. My naive method would be to add an entire new .ipynb file in the repo to test against, but I'm guessing that would be too 'bulky' for fastai style.
from nbdev.
Oh no, I was just saying: test is on fastpage with your own notebooks to make sure all works okay, not add some tests to nbdev. :)
from nbdev.
Oh, ok! Great.
I see that your version has "return cell" for that new line, whereas my version just has "return".
In running these on my test notebook file,Your version produces errors that halt the code (see below), whereas mine runs to completion but ...on closer inspection...produces output HTML which is slightly mangled -- the data:image parts load, but in the resulting HTML it has "paragraph symbols" (ΒΆ) at the right side of each markdown heading.
Output from export2html.notebook2html
with the nbdev currently in the official repo:
sequence item 1: expected str instance, NotebookNode found
Traceback (most recent call last):
File "_action_files/nb2post.py", line 37, in <module>
export2html.notebook2html(fname='_notebooks/*.ipynb', dest='_posts/', template_file='_action_files/fastpages.tpl')
File "/home/shawley/nbdev/nbdev/export2html.py", line 432, in notebook2html
raise Exception(msg + '\n'.join([f.name for p,f in zip(passed,files) if not p]))
Exception: Conversion failed on the following:
2019-12-21-PCA-From-Scratch.ipynb
from nbdev.
I thought your line was weird but mine was worse ;). Tried something else to unify the approaches, let me know if it works better.
from nbdev.
I think it's fine now, thanks. But to be sure, would you mind taking a look the HTML output for the nbdev/nbs/tutorial.ipynb
page that I just created using your newest export2html
code, to make sure it looks like you want it to?
Posting it here: https://hedges.belmont.edu/~shawley/2020-02-18-nbdev-tutorial.html
It also has the "paragraph symbols", and I'm not sure if they're supposed to be there.
from nbdev.
...wait, none of the inline math is rendering now, such as
Full-line math (with $$) is rendering ok in one of my notebooks, but not in another.
from nbdev.
As per fastai/fastpages#71, HTML "<img src" is getting translated into Liquid "{% img" by nbdev. This breaks embedded image objects because Liquid can't handle the long strings.
Might prefer for nbdev to leave "<img src" as is, and not translate it to Liquid.
from nbdev.
Related Issues (20)
- fastai/workflows/quarto-ghp@master failing and reporting "no module named 'pandas' HOT 1
- nbdev_install_quarto doesn't work with Windows 10 system HOT 1
- Blog post broken links
- Add code folding for `exports`
- Move `exports` source after the show_doc
- Add magic `__` symbols to `show_doc` output
- Remove boxes since they broke ToC
- UnboundLocalError: cannot access local variable '_TEMPLATE' where it is not associated with a value HOT 2
- Auto-trust notebooks after `nbdev_clean`
- add `nbdev_requirements`
- Direct invocation of setup.py deprecated when uploading package to PyPi
- nbdev_docs doesn't provide location of error
- Doc error: line number is `None`
- matplotlib outputs text representation instead of figure
- Add support for copying output files to website
- Python 3.12 No module named 'pkg_resources' HOT 3
- nbdev_install_quarto does not work in Windows HOT 1
- Error in index.ipynb after setting up nbdev-hello-world repo on a new Windows machine
- Question: How to make **multi-language** documentation for a nbdev project?
- notebooks with auto in their name are skipped in doclinks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbdev.