Comments (5)
You can - you just need to create new file with one of the following extensions:
- ojs
- omd
- ojsnb
from vscode-ojs.
Could you explain how?
When I create an new file with an ojs extension, it says "Observable JavaScript (OJS)" in the lower right, but it just behaves like a regular JavaScript file, and I don't see how to create a new cell.
By contrast, for Jupyter, there is a "Create: New Jupyter Notebook" command. It creates an unsaved file named "Untitled-1.ipynb" with a blank cell. I can type '2+2' and shift-return, and it execute and return 4.
The only way I see to get an ojs notebook that works is with the "OJS: Download Notebook" command.
Edit: I see now, the extension to use is .ojsnb. But what are the other extensions for?
from vscode-ojs.
An OJS file is essentially one big Observable Cell, without being limited to one statement, so the following would be valid:
md`# Hello Wold ${mol}`;
mol = 42;
{
const context = DOM.context2d(width, height);
let frame;
(function tick() {
const x = (Math.sin(Date.now() / 1000) + 1) / 2 * (width - 2 * radius) + radius;
context.clearRect(0, 0, width, height);
context.beginPath();
context.arc(x, height / 2, radius, 0, 2 * Math.PI);
context.fill();
frame = requestAnimationFrame(tick);
})();
invalidation.then(() => cancelAnimationFrame(frame));
return context.canvas;
}
radius = 11;
height = 22;
OMD docs are essentially markdown documents, that expect valid ojs inside code pips:
from vscode-ojs.
Thanks!
Clearly, I wasn't reading very carefully. Sorry about that!
In retrospect, I picked the .ojs extension because it was the first one listed and you use 'OJS' as an abbreviation for the Observable JS extension itself, so I thought that was the main file extension to use. But .ojsnb is the one that behaves like a notebook.
I think that for the other extensions, if it's going to display the result for each 'cell', it might make sense to also display the variable name? Showing 'height = 22' in the output would be more meaningful than just '22'.
Displaying the source code that generated the variable might make sense too? On the Observable HQ website, you can choose whether to expand or collapse the source code for each cell. Similarly, it would make sense for the author of a Markdown document to somehow decide whether to show the source code for each 'cell' as well as what the expression evaluated to.
from vscode-ojs.
Thanks for the feedback - In the past I have debated this with myself as well and with the addition of the "ojsnb" support decided that it catered for the folks who wanted similar features.
I think the OMD format has scope to add additional meta information (next to the pips) per code cell, but for OJS it would be an all or nothing type switch (like a "debug" mode in the preview pane).
FWIW - If you use the "export to HTML" feature:
You will see that I am simply reusing the official Observable "Inspector" to render the cells.
from vscode-ojs.
Related Issues (20)
- Add OJS/OMD Preview WebviewPanelSerializer HOT 3
- setState/getState tweak
- Auto-import default Inputs, d3, vl and Plot libraries for the new OJS notebooks that use them HOT 3
- Add support for HTML and TeX cells HOT 1
- Narrow notebook content width in exported html webpage view HOT 8
- Clarify OJS settings and review Preview errors HOT 3
- Activate OJS extension on "import" HOT 3
- Provide notebook UI using VS Code Notebook API HOT 1
- command 'ojs.import' not found HOT 5
- Preview to Web Page works as expected but Export to HTML does not work HOT 4
- fs/system apis HOT 5
- Thank you for making this. HOT 1
- How to debug notebooks? HOT 2
- Add web extension support HOT 4
- "Failed to fetch" error when importing within .ojsnb after VSCode restart HOT 1
- Repeated Code Execution Issue in OJS - "RuntimeError: x is defined more than once" HOT 4
- Fetch error HOT 5
- Add this OJS extenion to Data Science, Visualization and Notebooks categories in vscode & marketplace
- Add Observable JS Notebook Inspector to docs
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 vscode-ojs.