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

feat: shortcode for Jupyter Notebook #337

Merged
merged 8 commits into from
Sep 14, 2024
Merged

feat: shortcode for Jupyter Notebook #337

merged 8 commits into from
Sep 14, 2024

Conversation

imfing
Copy link
Owner

@imfing imfing commented Mar 29, 2024

Experimental shortcode to include jupyter notebook in a page. In the future, it will enable using a notebook file as an individual page.

Example usage:

---
title: Jupyter Notebook
math: true
---

{{< jupyter "Intro.ipynb" >}}

image

Copy link

netlify bot commented Mar 29, 2024

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit f8dd5fb
🔍 Latest deploy log https://app.netlify.com/sites/hugo-hextra/deploys/66e58f5482fa390008dae987
😎 Deploy Preview https://deploy-preview-337--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dogweather
Copy link
Contributor

Very cool, thank you.

@imfing imfing added the enhancement New feature or request label Mar 30, 2024
@imfing imfing added this to the v0.8.0 milestone Mar 30, 2024
Repository owner deleted a comment from notion-workspace bot Apr 9, 2024
@MattDodsonEnglish
Copy link

Hi @imfing This is great! I just tested this branch for a use case and it worked perfectly. If I had any complaint, it'd be that I'd prefer host the notebooks in the same directory, like static, and I couldn't figure it out with page.Resources. But that's a minor thing.

Just wondering, is there any reason you don't want to merge this to main? I would start using it right away.

@MattDodsonEnglish
Copy link

. If I had any complaint,

Ah, one other: it seems the headings don't show in the ToC, having tried with both % and < tokens. I'm not sure how to fix that one yet, but I'll dig into the rendering logic and see if I can find a solution.

@imfing
Copy link
Owner Author

imfing commented Aug 26, 2024

@MattDodsonEnglish Thank you for the feedback.

I would start using it right away.

I think I will probably merge this as is once I resolve the conflicts.

Just wondering, is there any reason you don't want to merge this to main?

I didn't figure out a way to make Jupyter work nicely in Hugo so that we can essentially use jupyter notebooks instead of .md files. But this can be addressed separately.

If I had any complaint, it'd be that I'd prefer host the notebooks in the same directory,

This can be supported as what we can do for images: https://imfing.github.io/hextra/docs/guide/organize-files/#add-images

Ah, one other: it seems the headings don't show in the ToC

I'll try to address this, but I'm not sure if this is a easy thing.

@MattDodsonEnglish
Copy link

Ah, one other: it seems the headings don't show in the ToC

I'll try to address this, but I'm not sure if this is a easy thing.

From what I tried, I don't know how easy this is to do it elegantly. Using something like this with % works to make a ToC, but it causes a lot other issues, like requiring two lines two surround all markdown blocks, and things like embedded callout shortcodes fail.

      {{- if $toc -}}
        {{- $sourceContent -}}
      {{- else -}}
        {{- $sourceContent | $page.RenderString -}}
      {{- end -}}

@MattDodsonEnglish
Copy link

One more request: would it be possible to keep the copy button in the cells? It's a nice UX boost for readers who just want to grab a little sample from the wider notebook flow.

@imfing
Copy link
Owner Author

imfing commented Sep 14, 2024

@imfing imfing merged commit 2af73b3 into main Sep 14, 2024
4 checks passed
@imfing imfing deleted the jupyter branch September 14, 2024 13:29
@MattDodsonEnglish
Copy link

@imfing preliminary test looks great, with ToC too. Thanks 🙇

@imfing
Copy link
Owner Author

imfing commented Sep 16, 2024

@MattDodsonEnglish let me know if things don't work as expected 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants