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

URLs in Code cells get mangled #104

Closed
TylerLeonhardt opened this issue Mar 17, 2020 · 7 comments
Closed

URLs in Code cells get mangled #104

TylerLeonhardt opened this issue Mar 17, 2020 · 7 comments

Comments

@TylerLeonhardt
Copy link

TylerLeonhardt commented Mar 17, 2020

Original issue over in fastpages fastai/fastpages#215

Take a look at this notebook and scroll down to the NOTE.
https://tylerleonhardt.github.io/blog/jupyter/powershell/pswordcloud/2020/03/16/Word-Clouds.html

I'm using a magic command #!markdown to render markdown instead of a normal code block so I can show the markdown code behind it.

Unfortunately, for some reason fastpages mangles the path of my svg in the code sample:

![.NET Interactive codebase word cloud](/blog/images/copied_from_nb/dotnet-interactive.svg)

instead of

![.NET Interactive codebase word cloud](dotnet-interactive.svg)

which is what it is in source:
https://github.com/TylerLeonhardt/blog/blob/56e0f224d03866fd5118131ab41bcb8effb81453/_notebooks/2020-03-16-Word-Clouds.ipynb#L110

Expected Behavior

My url isn't touched.

![.NET Interactive codebase word cloud](dotnet-interactive.svg)

Actual Behavior

My url is mangled.

![.NET Interactive codebase word cloud](/blog/images/copied_from_nb/dotnet-interactive.svg)

Proposed solution

Don't expand image tags in Code blocks?

More context

so #!markdown is exposed by .NET Interactive:

https://github.com/dotnet/interactive

Which is a new hybrid-language kernel that supports the ability to call upon languages within different cells using magic commands

It supports:

C#, F#, PowerShell, JavaScript, HTML, Markdown

If the default language is PowerShell, for example, and I want to have a cell use Markdown, I can use the #!markdown magic command

Now I can agree that a #!markdown magic command is kinda silly because.. well... that's what a Markdown cell is for...

But the difference is that you see the markdown in addition to the output.

I guess It'd be the equivalent to a Markdown cell of:

## my markdown code

My markdown code

@TylerLeonhardt
Copy link
Author

I've also been told to @jph00 by @hamelsmu because you might be interested in PowerShell notebooks! 😅

Let me know if there's anything else I can help with!

@hamelsmu
Copy link
Member

hamelsmu commented Mar 17, 2020

I can confirm that this happens. I was able to reproduce this issue.

Another way of explaining it is if you have markdown syntax for images in a code cell, nbdev will change the path as if though its a markdown cell.,

Granted, I have never tried to put markdown in a code cell before, especially in a Jupyter Notebook, but @TylerLeonhardt has a legit use case where needs to do this for PowerShell Notebooks.

@sgugger
Copy link

sgugger commented Mar 18, 2020

Added a test for markdown cells (it was forgotten by mistake). Thanks for flagging the issue!

@TylerLeonhardt
Copy link
Author

Thanks @sgugger! @hamelsmu, how will I get this fix in fastpages?

@hamelsmu
Copy link
Member

You cannot yet - I had to pin the version because of another nbdev bug which will prevent you from enjoying this fix.

I’m going to help test that and then Sylvian will cut another release.

TLDR; you can’t yet but I’ll comment on this thread when it’s all ready and tested.

Thanks everyone for the coordination

@hamelsmu
Copy link
Member

Related issue is #105.

@hamelsmu
Copy link
Member

@TylerLeonhardt this should be ready now, you can proceed by just re-generating your pages and everything will just work. I don't even think you have to upgrade anything

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