-
Notifications
You must be signed in to change notification settings - Fork 130
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
observable convert #764
observable convert #764
Conversation
FYI we currently don't support requesting private notebooks via API keys as individuals, which would be a blocker for this. It is something that I've discussed with the gardening team as wanting to fix soon though. I think we understand the path of how to get there though, especially post workspace migration. |
Yep, I didn’t expect it to work yet — just noting it for future work! |
I will probably have to use this script in large quantities (say, to port over certain galleries…), and I wonder what I should do when I see a repeating pattern. Is it better to try and make this script smarter, or to write an independent script to use as a post-processor (and that matches what I care about without trying to be generic)? |
Fwiw, I'd be more than happy to help with that. |
I can’t do anything about As I said in the description, I think we could make this smarter in the future, but that anything smart should be opt-in or opt-out since it is unlikely to be correct in all cases. And so I think the best place to start is to simply preserve the user’s code with no edits. And of course you could pipe the output to a helper script for post-processing too. I’d also like this to be available for bulk conversion, too:
Perhaps this suggests that |
52d7732
to
efc5f91
Compare
Okay, this is ready — it just needs tests! |
I was surprised that the replace confirm would stop the whole operation; instead, I thought (given the wording of the question) that answering No would skip that file and continue to the next file. If we don't change that, the message in that case ("Cancelled convert") is slightly wrong: the download is in a partial state (what's been downloaded already is already here). It would be more accurate to say "Stopped convert". If we wanted to cancel, we should use a temp download directory and leave a clean slate if there is any error. Also, it seems strange to download a file then verify if we already have a copy. Happy to work on these changes if you think they make sense. But I don't want to block because this is still good enough to include today. |
convert the file names (scatterplot/2 should be "scatterplot,2") nicer log effects
skip documents and files we already have
ctrl-c still stops, as expected
f62026a
to
723a597
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving to unblock. a few thoughts:
- does it make sense to drop the md file directly into doc?
- the comma in the name feels rough
that said perhaps both of these are a good way to indicate that it's not always just gonna work and needs some inspection.
What does this mean? “drop the md file directly into doc?” |
ah yes sorry, assuming that |
Ah, yeah, maybe. Not sure yet how people will use it. 🙏 |
this should only happen when the original notebook's slug contains a
because we can't use a slash in a file name (the choice of a comma in that case is a little arbitrary, but it lowers the risk of conflicting with another notebook (e.g. |
A minimal implementation of converting an Observable notebook to Markdown. For example:
This outputs a plot-scatterplot,2.md containing:
You can also use shorthand:
This is mostly designed under the worse is better philosophy. I didn’t try to implement anything fancy, like parsing Observable JavaScript and rewriting it to vanilla JavaScript. The expectation is that it’ll probably break, but the code will be right there so it should be “easy” to rewrite the code manually. And in many cases, I don’t think we’ll be able to rewrite the code automatically. Maybe we could have some opt-in (or opt-out) smart rewrites in the future, but this feels like a useful thing to include to get things going!
I’d also like to allow it to use your credentials to convert private notebooks if you
observable login
.